PDA

View Full Version : glutMainLoopEvent() in another loop.



iKubik
12-18-2015, 05:44 AM
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?

carsten neumann
12-18-2015, 07:52 AM
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
, around source code snippets preservers their formatting.

iKubik
12-18-2015, 08:23 AM
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
, around source code snippets preservers their formatting.

...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.