Jump to content
  • Advertisement
Sign in to follow this  
mesor

Yet another noob prolem!!!

This topic is 4117 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

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!

Share this post


Link to post
Share on other sites
Advertisement
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 crap

int main (int argc, char **argv) {
glutKeyboardFunc(keyboard)
//here comes more crap
}

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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!

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!