Is it possible to replace glutMainLoop () with a simple loop?

Is it possible to replace glutMainLoop() with a simple loop (for example, while or for ) and in this loop just call all the callbacks?

I did this, and the image is displayed fine, but the window (in which the image is displayed) is not responding (cannot move it).

Does glutMainLoop() call more than callbacks?

+4
source share
3 answers

If you use FreeGLUT, you can use glutMainLoopEvent . It executes one event loop processing loop, so you can call it in a loop.

 while(...) { glutMainLoopEvent(); //do other stuff. } 
+14
source

glutMainLoop also handles all communication windows, so if you want to replace it, you will either need to use a (different) library for this, or write system code that allows communication with the operating system. There are many examples on the Internet, although at least for MS Windows.

Here, MSDN describes the main function of Win32.

+2
source

Does glutMainLoop () call more than callbacks?

Yes, it is his responsibility to manage the entire event, for example, receiving events from your graphics system. It then invokes callbacks with event data.

If you want to do your own event handling, do not use GLUT. There are other structures that give you a lower level of access to events and expect that you will perform all event scheduling. Take a look at GLFW and SDL.

+1
source

Source: https://habr.com/ru/post/1413511/


All Articles