Hello, I am writing a OpenGL program, but I can't get the mouse to do what I want.
The code looks like this
main()
[INDENT]init OpenGL stuff
display function1[/INDENT]
Function1
[INDENT]Start graphCalculation[/INDENT]
graphCalculation
[INDENT]plot graph in OpenGL[/INDENT]
What I've tried to do, is to add a "zoom" function, so the mouse looks like this:
mouseFunction
[INDENT]if button down
[INDENT]if left button, zoom in (get new coordinates), and execute graphCalculation
if right button, zoom out (get new coordinates), and execute graphCalculation
[/INDENT][/INDENT]
the C code looks like this:
void processMouse(int button, int state, int x, int y){
if(state == GLUT_DOWN){
if(button == GLUT_LEFT_BUTTON){
//passing new x,y coordinates to calculate new axis and redisplaying them
graphCalculation(x,y,0);
}
if(button == GLUT_RIGHT_BUTTON){
//passing new x,y coordinates to calculate new axis and redisplaying the
graphCalculation(x,y,1);
}
}
glutPostRedisplay();
}
This doesn't work, can anyone help me?
I know it's fairly long, but thanks :)
P.s The graph function works..