how to implement a continuous zoom with a mouse button hold...

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

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.

yes your suggestion worked great. It is much appreciated, thanks.