[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Python threads, pygame, and pyopengl
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Python threads, pygame, and pyopengl
- From: Zack Schilling <zack.schilling@xxxxxxxxx>
- Date: Tue, 12 May 2009 15:22:51 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 12 May 2009 15:47:47 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=GHoJScASz7Z+AsE38GsP13jvrFKcvsVS0qSU0FwBNGs=; b=tC0KGJ04MBPGXc89B3bWWE/52VShgUp5eZVeZguk+mYAB+y+C+kpUQk8FVd24AoimX lZ+asy9MeXygOUAzvHRmPzrikuJd2GH0tUOjBdmcOaLcYmg9zgsJh00yorF5NvNY6ixA s+BJ+Rkh70487HJlME/BlZhZE80fAhY/w/+uU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=cUR+KQYlvxT7oC2vG2S5QRCs72Zr8lTBfEHXARwL1yJBbvotWrJPzastwxaABJAc+6 pI7tDTzG89I5/zD0DwUCTHJVhMXc+B0OMh8xfI/hqq+f/nNncnM57hjQ8li+dLXbmK1p ueQzV5t81h0UEiwtiBH/6raDdjwrGlPOMJwVQ=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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