Yet another noob prolem!!!

Started by
5 comments, last by mesor 16 years, 10 months ago
im not sure if this thread belongs here but let`s try ;) i have this code

void keyboard (unsigned char key, int x, int y) {
if (key==27) {exit (0);}
else if (key==60){d=0}
else if (key==62){d=1}
}
Then i call that function in the glutKeyboardFunc. the problem is that d doesnt keep the value asigned by the keyboard function. but the one define in the begining! some idea? thx!
Advertisement
where is the declaration of d ?
you snippet doesn't give (me) any clue.
i declare d at the begining


#include <fstream>char FTLoad[256]="/mnt/backup/mdv/OpenGL/textura/panel.bmp";int d=0;using namespace std;void keyboard (unsigned char key, int x, int y) {if (key==27) {/*exit (0)*/d=1;}else if (key==60){d=0;}else if (key==62){d=1;}}//here comes more crapint main (int argc, char **argv) {glutKeyboardFunc(keyboard) //here comes more crap}
So you push '2' and d doesn't change to 1? Maybe you should slip in a printf("%c pushed, d is %d\n",key,d); at the end of your function for debugging. It will let you see if d is really getting changed. Perhaps it's getting reset elsewhere?
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
thank you all!
its working!
i dont know why but......
Well, what changed? Just fixing it isn't as good as understanding why it works now.
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Quote:Original post by erissian
Well, what changed? Just fixing it isn't as good as understanding why it works now.

100 % agree!!!!
but i have no idea!
i guess that it vas working but the problem was other from the beging. I dont know!
sorry!
thanks all!

This topic is closed to new replies.

Advertisement