Ooops - in the enclosed code, there ought to be a call to
w.switch_to() in the recalcMatrices function, I imagine. The behavior
remains the same, though.

On Sep 25, 11:41 am, "Dave LeCompte" <[EMAIL PROTECTED]> wrote:
> Hi, I've just begun exploring Pyglet, and I've stumbled on something that
> doesn't make sense to me.
>
> I've been experimenting with creating windows, resizing them, and calling
> gluOrtho2D to set their projection matrix. It seems that if the window is
> resized, the projection matrix is incorrect.
>
> Following is a small script that creates two windows, one with the default
> 640x480 size, which then gets resized to 256x256, and a second which gets
> created at 256x256 to begin with. I call gluOrtho2D in each case to the same
> value, and in my update loop, I draw a triangle. I would expect each window
> to draw the triangle in the same way, but the triangle doesn't appear on the
> window that was resized from 640x480.
>
> A telling clue is shown when the user resizes the windows by dragging on the
> border - the missing triangle can be found by resizing the "resized" window
> back to around 640x480, as though there was some initial state that's not
> properly updated when I do the resize. Also, when the user resizes the
> window that started off at 256x256, the triangle remains the same size
> onscreen (64x64 pixels, a quarter of the window's original dimensions),
> while I would expect the triangle to resize to be a quarter of the window's
> new dimensions.
>
> At a guess, I'm thinking that the very last step in the view pipeline that
> converts to actual device(window) coordinates still knows about the original
> window's size.
>
> I did a glGetFloatv(GL_PROJECTION_MATRIX) on both windows (not shown in the
> included code), and the values are identical.
>
> I also tried replacing gluOrtho2D with glOrtho, and the results are the
> same.
>
> Am I forgetting a step to make the orthographic projections work properly?
> Or is it, in fact, working properly, and I'm expecting it to behave
> differently than it's designed to?
>
> I'm running on Windows XP, Python 2.4, with a Pyglet version I got from SVN,
> version 1272.
>
> Thanks,
> Dave LeCompte
>
> =======
>
> from pyglet import window
> from pyglet.gl import *
>
> allWindows=[]
>
> def onWindowResize(width,height):
>     print "window size",width,height
>     recalcMatrices()
>
> def recalcMatrices():
>     for w in allWindows:
>         print "resetting projection matrix for window",w.caption
+         w.switch_to()
>         glMatrixMode(GL_PROJECTION)
>         glLoadIdentity()
>         gluOrtho2D(-1,1,-1,1)
>         glMatrixMode(GL_MODELVIEW)
>         glLoadIdentity()
>
> w=window.Window(caption="resized", resizable=True)
> w.set_size(256,256)
> w.on_resize=onWindowResize
> w.set_location(50,50)
> allWindows.append(w)
>
> w=window.Window(256,256,caption="pristine", resizable=True)
> w.on_resize=onWindowResize
> w.set_location(350,50)
> allWindows.append(w)
>
> recalcMatrices()
>
> running=True
> while running:
>     for w in allWindows:
>         w.dispatch_events()
>
>         if w.has_exit:
>             running=False
>
>     for w in allWindows:
>         w.switch_to()
>         glClear(GL_COLOR_BUFFER_BIT)
>
>         glBegin(GL_TRIANGLES)
>         glColor3f(1.0, 0.0, 0.0)
>         glVertex2f(0.0,0.0)
>         glColor3f(0.0, 1.0, 0.0)
>         glVertex2f(0.5,0.0)
>         glColor3f(0.0, 0.0, 1.0)
>         glVertex2f(0.5,0.5)
>         glEnd()
>
>         w.flip()


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to