I want to dynamically load levels for my game in python. I use OpenGL
for drawing, mostly display lists. I want to spawn a low-priority
thread that can create a new level object and activate its load
method. The load method takes up to 5 seconds to run. It is loading
images with pygame, splitting them up, generating large numpy arrays,
binding textures, and building display lists. I know that if I simply
create a thread and tell it to go without any modification, the OpenGL
calls building the display lists in the loading thread will overlap
with normal display code and cause strange, flickery drawing (not to
mention ruining the level being loaded).
What's the best option here? Can a thread lock block the main
program's execution? Because that's where the drawing code is. Is
there a way to set up PyOpenGL so that OpenGL knows to separate the
two different voices talking to it (but still throw everything into
the same context)?
This game is a fun project for me, but I also expect to plow my way
though some advanced programming techniques, so don't hold back
suggestions for the sake of complexity.
Thanks,
Zack
- [pygame] Python threads, pygame, and pyopengl Zack Schilling
-