glutKeyboardFunc() problems

Started by
0 comments, last by dmatter 13 years, 8 months ago
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.
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).

This topic is closed to new replies.

Advertisement