So I have an extremely simple application (on cygwin python) that has a
scheduled function to perform updates:
class Example(pyglet.window.Window):
def __init__(self):
super(Example, self).__init__(300, 200, resizable=False)
glEnable(GL_DEPTH_TEST)
self.angle = 0
clock.schedule_interval(self.on_update, 1.0/20)
def on_update(self, dt):
self.angle = (self.angle + 60*dt) % 360.0
def on_draw(self):
self.clear()
glLoadIdentity()
glTranslatef(0.0, 0.0, -3.0)
glRotatef(self.angle, 0.0, 1.0, 0.0)
pyglet.graphics.draw_indexed(8, GL_TRIANGLES,
[0, 1, 2, 2, 3, 0,
4, 5, 6, 6, 7, 4,
0, 1, 4, 1, 4, 5,
2, 3, 6, 3, 6, 7,
1, 2, 5, 2, 5, 6,
0, 3, 4, 3, 4, 7],
('v3i', (-1,-1, -1,
1, -1, -1,
1, 1, -1,
-1, 1, -1,
-1,-1, 1,
1, -1, 1,
1, 1, 1,
-1, 1, 1)),
('c3B', (0, 0, 255,
0, 255, 0,
255, 255, 0,
255, 0, 0,
255, 255, 0,
255, 0, 255,
255, 255, 255,
0, 255, 255)))
def on_key_press(self, symbol, modifiers):
if symbol == key.ESCAPE:
exit()
def on_resize(self, width, height):
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(90, width / float(height), .1, 1000)
glMatrixMode(GL_MODELVIEW)
return pyglet.event.EVENT_HANDLED
def on_show(self):
return pyglet.event.EVENT_HANDLED
def on_hide(self):
return pyglet.event.EVENT_HANDLED
if __name__ == '__main__':
window = Example()
pyglet.app.EventLoop().run()
But this fails to update, unless I keep giving it events (like moving the
mouse over the window. If I stop the mouse, the cube stops spinning)
If I change the line in pyglet/app/win32.py (line 105, in
Win32EventLoop._timer_func) to self._polling = True from self._polling =
False it works! But as I'm not entirely sure what the logic is, I'll pass
this on.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pyglet-users/-/A9AFddycLSAJ.
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.