Re: [PyOpenGL-Users] Anyone have a working script using PyOpenGL with threads?
Brought to you by:
mcfletch
|
From: <il...@ya...> - 2002-07-25 00:13:08
|
Hi.
I've used threads before with pyopengl. I use them
when flipping the backbuffer. As on some(many?)
machines you have a lot of free cpu time which
otherwise gets wasted.
the code I used is old and rotten :) It relies on
other code which has morphed into other stuff. So
I'll paste the thread parts.
from threading import Thread
import threading
class SomeThread(Thread):
def __init__(self):
Thread.__init__(self)
self.an_event = threading.Event()
def run(self):
# do some calculations here.
map(cos, xrange(1000))
a_thread = SomeThread()
Then in the main loop(this is with pygame which allows
you to have a main loop).
DrawOpenGLStuff()
# start off thread.
if not (threading_activeCount() > 1):
a_thread.start()
# flip back buffer
pygame.display.flip()
I guess this is not how you want to use threads.
Maybe you could post some code that we could test?
The problem might be to do with your driver/platform.
--- "Mike C. Fletcher" <mcf...@ro...> wrote: >
I've been trying to make OpenGLContext use a model
> where a background
> server thread does the rendering to allow foreground
> threads to be
> application-specific & largely unconcerned with the
> rendering operations.
>
> However, whenever I try to put the rendering thread
> in the background,
> the entire works gets gummed up, with the symptoms
> looking like the
> OpenGL calls just aren't writing to the buffers at
> all (the results from
> previous runs are present, along with random data,
> etceteras), though
> the swap-buffers methods seem to be working for both
> GLUT and wx. I'm
> using the context.setCurrent equivalents for the
> various contexts, BTW.
>
> I'd love to see a script using threads + OpenGL so I
> can figure out what
> I'm doing wrong here. I assume it's something dumb,
> but I can't figure
> out what.
>
> Any help appreciated,
> Mike
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
|