Jump to content
  • Advertisement
Sign in to follow this  
pkiskool

OpenGL Clicking problem

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

Hi, I'm very new to openGL, and I'm not doing a game developing, I'm using it towards my master's study in mechanical engineering. I have a funky problem which some of you experts might laugh at, but it's no laughing matter for me so I hope someone could help me out. I have a special key which activates a function - let's say the button 't'. I only want this function to be turned on when pressing 't', but for some reason after pressing 't' once, I can also activate it with a mouse click on the window. Matter of fact, ANY key will run the function AFTER the pressing of 't' once. I have a feeling that this is due to a improper placement of my functions, but as I've mentioned I'm fairly new to this game of openGL and the c++ coding. I won't post the details of the code but I'll briefly illustrate the structure. void RenderScene(void) { if (GeometryFlag==true) front(); . . . . } void OtherKeys(unsigned char key, int z, int a) { if(key == 't') { if (GeometryFlag==false) GeometryFlag=true; else if (GeometryFlag==true) GeometryFlag=false; } . . . } int main (int argc, char **argv) { . . . glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800,600); glutCreateWindow("Flow Front"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); glutKeyboardFunc(OtherKeys); SetupRC(); glutMainLoop(); } I didn't include all the functions - some are obvious like SetupRC(); etc... I also have a zoom in and out key within the OtherKeys function, but there seems to be a some funkyness in there as well. After pressing 't' once, then the '+' key to zoom, pressing anything after that would do both running the front() function (which is activated by 't') AND zooming in at the sametime.... Someone please help!!!

Share this post


Link to post
Share on other sites
Advertisement
The code you posted looks fine, but it's so skeletal that whatever's causing the problem is most likely elsewhere.

This sort of problem is very easy to find and resolve using the debugger. I'd suggest going that route. If you don't yet know how to use the debugger, now's the time to learn.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!