On Sun, Dec 28, 2008 at 9:36 PM, Simon Wittber <[email protected]> wrote: > > The window.on_resize event is not behaving as I expected. In the code > below, I use glOrtho to set up a projection with (0,0) at the center > of the screen. It seems that the projection being set up by the > window.on_resize function is being ignored. The fps display should be > drawn in the center of the screen. Instead, it is being drawn at the > bottom left of the screen, which pyglet's default projection. > > Is this a bug or am I doing something wrong? > > > import pyglet > from pyglet.gl import * > > fps = pyglet.clock.ClockDisplay() > > window = pyglet.window.Window(800, 600) > > @window.event > def on_draw(): > window.clear() > fps.draw() > > @window.event > def on_resize(width, height): > glMatrixMode(GL_PROJECTION) > glLoadIdentity() > width *= 0.5 > height *= 0.5 > glOrtho(-width, width, -height, height, -1, 1) > glMatrixMode(gl.GL_MODELVIEW) > glLoadIdentity() > > > pyglet.app.run()
I believe this is because you're attaching the event handler after the window has already been displayed (and initially sized). Adding visible=False to the constructor and calling window.set_visible() before run() should fix the issue. Alex. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
