glutMainLoopEvent() in another loop.

Hello,
I’m working on a simple app which captures image from webcam and draws something in OpenGL. I have a problem, because my function works in infinite loop and GLUT works in it’s own loop. I decided to work with FreeGLUT, because it can control glutMainLoop(). My function look like this:


for(;;)
{
  Capture image from webcam, and track points using Lucas-Kanade method.

  Draw something in OpenGL window using FreeGLUT and glutMainLoopEvent().
}

It’s not working perfectly, because it captures one frame from camera, later draws one frame in OpenGL and exits.
I don’t want to exit after only one iteration of my main loop, I want to loop this process. How can I achieve this?

That is not what is supposed to happen when using glutMainLoopEvent(). Are you perhaps calling exit()/abort() from any of your GLUT callbacks, throw an uncaught exception, or simply crash? Because outside of one of these “abnormal” program termination cases I don’t see how glutMainLoopEvent() could end your infinite for loop…

PS: using [noparse]

,

[/noparse] around source code snippets preservers their formatting.

[QUOTE=carsten neumann;1280734]That is not what is supposed to happen when using glutMainLoopEvent(). Are you perhaps calling exit()/abort() from any of your GLUT callbacks, throw an uncaught exception, or simply crash? Because outside of one of these “abnormal” program termination cases I don’t see how glutMainLoopEvent() could end your infinite for loop…

PS: using [noparse]

,

[/noparse] around source code snippets preservers their formatting.[/QUOTE]

…yes, in windows console I had “freeglut illegal glutInit() reinitialization attempt”. I’m not used to coding on Windows, so I missed it. I had glutInit() in my main loop, that was a mistake.