in reply to OpenGL and AnyEvent

From a quick googling, it seems that at least some GLUT implementations, freeglut and openglut implement glutMainLoopEvent(), which is supposed to be called periodically from your other mainloop.

A second alternative would be to detach OpenGL processing from the rest of your program by using a separate thread to handle OpenGL. But then you need to make sure that all OpenGL-related resources get allocated from that thread. At least, I remember some stories of debugging two threads going tag-team on OpenGL handles in the early days of consumer OpenGL.

Replies are listed 'Best First'.
Re^2: OpenGL and AnyEvent
by basiliscos (Pilgrim) on May 29, 2014 at 12:34 UTC

    Thank you, Corion!

    I've found that the main trick is to call glutPostRedisplay too, e.g. instead of glutMainLoop

    my $refresh_world = sub { glutMainLoopEvent; glutPostRedisplay; }; my $t; $t = AE::timer 0, 0.01, sub { $refresh_world->(); }; $refresh_world->(); AE::cv->recv;