PDA

View Full Version : how to implement a continuous zoom with a mouse button hold...



jdaniel
02-12-2004, 05:49 AM
Hello,

I am attempting to implement a continuous zoom ability with the processMouse glut function. For example...

void processMouse(int button, int state, int x, int y) {

if (button == GLUT_LEFT_BUTTON) {

zoom += .1f;

}
}


This will work but requires my users to keep clicking the mouse button for each zoom increment. I have been unsuccessful implementing a continous zoom animation when my user presses and holds the mouse button. Any attempt usually results in an infinite zoom loop that can't be broken until the process is killed.

Any help on this matter would be much appreciated.

Thank You,
jdaniel

hanz
02-15-2004, 09:25 PM
elo mate...maybe i can help you out. Just try it and let me know.

just create an idle function
void zoom(void)
{
z += .1;
glutPostRedisplay();
}

Do not register any idle function in your main function but in your mouse function create conditions. For example
if (button == GLUT_LEFT_BUTTON)
glutIdleFunc(zoom);

This should work.

jdaniel
02-16-2004, 06:16 AM
yes your suggestion worked great. It is much appreciated, thanks.