问题
Both GLUT and libdispatch have their own event-handling loops, which are invoked with functions that never return: glutMainLoop();
and dispatch_main();
, respectively.
I've tried:
dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(q, ^{
glutMainLoop();
});
dispatch_main();
...and the window displays, but does not respond to any events or redraw after the initial call to the function specified with glutDisplayFunc()
.
How can I get GLUT and libdispatch to play nicely together?
回答1:
You can't. Both of them want to own the message processing loop. And since there's only one such loop, they can't both own it.
If you used FreeGLUT, you could find a way to make that work. But a better alternative would be to just use GLFW.
来源:https://stackoverflow.com/questions/12553563/how-to-use-glut-with-libdispatch