Jump to content
  • Advertisement
Sign in to follow this  
Oni Sephiroth

glutKeyboardFunc() problems

This topic is 2953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having some problems with this and the parameter, it's not allowing me to pass a function to it.

#include "inputManager.h"

CkeyboardTrigger * CkeyboardTrigger::_singleton;

CkeyboardTrigger::CkeyboardTrigger()
{
CBaseEvent * keyDown = new CBaseEvent();
CBaseEvent * keyUp = new CBaseEvent();
CBaseEvent * mouseClick = new CBaseEvent();
CBaseEvent * mouseRelease = new CBaseEvent();

_addEvent(keyDown);
_addEvent(keyUp);
_addEvent(mouseClick);
_addEvent(mouseRelease);

glutKeyboardFunc(_keyboard);
}

void CkeyboardTrigger::_keyboard(unsigned char key, int x, int y)
{

}

CkeyboardTrigger * CkeyboardTrigger::initialize()
{
if (!_singleton)
_singleton = new CkeyboardTrigger();

return _singleton;
}

CkeyboardTrigger::~CkeyboardTrigger()
{
if (_singleton)
delete _singleton;
}


the constructor and the _keyboard function is the part in question...
The error I'm getting back is

error C3867: 'CkeyboardTrigger::_keyboard': function call missing argument list; use '&CkeyboardTrigger::_keyboard' to create a pointer to member

I tried what it said and put the &CkeyboardTrigger::_keyboard infront of it, but got no luck. Am I missing something here? I looked up the error code as well and found nothing that would compile.

Share this post


Link to post
Share on other sites
Advertisement
glutKeyboardFunc asks for a function pointer of type:

void (*)(unsigned char key, int x, int y)

You're giving it a function pointer of type:

void (CkeyboardTrigger::*)(unsigned char key, int x, int y)

As you can see, the problem is that _keyboard is a non-static member function. You need to either move it out of the class, or make it static.

(Remember that GLUT is a C library, there were no classes in C).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!