I have a certain problem with an idiotic keyboard class I’m supposed to use instead of the regular methods that facilitate the interaction with the keyboard. My class is the following:
class Keyboard
{
public:
static void
keyDown(unsigned char key, int x, int y)
{
_keyboard[key]=true;
}
static void
keyUp(unsigned char key, int x, int y)
{
_keyboard[key]=false;
}
static bool
isPressed(char c) { return _keyboard[c]; }
// private:
static bool _keyboard[256];
};
bool Keyboard::_keyboard[256];
Keyboard *k;
Now I guess that all my code lines are correct: I create a brand new method for my keyboard operations, I call it from the ‘display’ method, I have these 2 paramount lines in the main function :“glutKeyboardFunc(Keyboard::keyDown);
glutKeyboardUpFunc(Keyboard::keyUp);”, and I try to test it by “fprintf(f,”%d",k->_keyboard[’>’]);
fprintf(f,"
%d",k->isPressed(’>’));" transfering the result to an output file.
And… the result is: 0 0.
What may my problem be? I admit I am at my very first attempts to handle OpenGL techniques, yet as this is a forum with regard to beginners I hope my question will not be reckoned as too stupid. Thank you!