Sign in to follow this  

Yet another noob prolem!!!

This topic is 3868 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
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
Well, what changed? Just fixing it isn't as good as understanding why it works now.

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

This topic is 3868 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this