问题
I have a program which updates it the program output then the state of the program changes. This happens when a ticker of the time (not an openGL timer, one implemented in threads) happens, and when keyboard input is registered from glut (using glutKeyboardFunc callback).
Both of these events update the programs state and call glutPostRedisplay; the problem is only the when the keyboard is pressed does it actually do anything. When the timer ticks the display function is ignored, but when the keyboard is pressed the display function is called.
Does glut ignore other threads? And if so is there a way to get it to register them.
回答1:
You cannot call glutPostRedisplay
or most other GLUT functions from a thread other than the one GLUT was initialized in. GLUT is not thread-safe.
来源:https://stackoverflow.com/questions/9725681/threading-with-glut-glutpostredisplay-being-ignored