PDA

View Full Version : Passing parameter to glutKeyboardFunc



TolTol
12-12-2002, 01:11 AM
Hi all,
I have a bit of a problem. I what to pass an extra parameter to glutKeyboardFunc.
Showing the code will make it easier to explain:

glutKeyboardFunc(myKeyboard);

void myKeyboard(unsigned char thekey, int x,int y){
array_of_bool[thekey]=true;
}

The problem is that I cant find any way of passing array_of_bool to myKeyboard.

I cant declare array_of_bool as a global .

Any suggestions on how to pass array_of_bool to the function???

Thanks in advance.

[This message has been edited by TolTol (edited 12-12-2002).]

Bob
12-12-2002, 02:10 AM
Why can't you make it global? What are you trying to do? There may be other ways to solve your problem than passing it via the function, which is, by the way, not possible.

Rob Fletcher
12-12-2002, 02:48 AM
If you can't make it global, then other than a different solution to what you are trying to do ... the answer is NO, unless ...

You edit your GLUT source code and ADD an extra arg to the glutKeyBoardFunc() !!!

Or, perhaps more elegant, add a void* pointer to the end of the window structure, so you can point this to your own data structure which will be carried around on a per window basis ...

Oh the need to do SOMETHING with glut ...

Rob.