Hi there,
I've been playing around with pyglet in order to get some offscreen
rendering to work. I want to render simple shapes and convert them to
numpy arrays. Following the advice given in
http://groups.google.com/group/pyglet-users/browse_thread/thread/71cb064ee1f11714/d105bfa9909eb2f3?lnk=gst&q=offscreen#d105bfa9909eb2f3
, I created an invisible window and didn't call app.run(). For now,
I'm just rendering on screen. My code looks something like this:
window = pg.window.Window(visible = False)
window.set_size(10,10)
window.clear()
drawTriangle( )
window.flip()
x = screenAsArray() # Does a screencapture and converts to numpy array
This doesn't work, so I thought that maybe I could just start and stop
the event loop for one frame whenever needed. So I tried something
like this:
if __name__ == "__main__":
window = pg.window.Window()#visible = False)
window.set_size(10,10)
@window.event
def on_draw():
window.clear()
drawTriangle()
x = screenAsArray()
pg.app.exit()
pg.app.run()
This works, but ONLY if I make the pg.app.run call where it is in the
above example. When I place it in another function or enter it in the
interpreter, it doesn't work. It does work when I leave the run call
where it is, so that it renders one frame, and then call pg.app.run
again in the interpreter later.. Does anyone know what's going on
here?
I would preferably get the first method to work. It seems like app.run
does some initialization work that I'm not doing in the first code
snippet above.
Any help is appreciated.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.