The problem is that the standard window on_resize is invoked after the
perspective projection is set up. I've checked in a fixed version (attach
setup() as the on_resize method on the windows) to SVN.
Alternatively, we could alter the demo to use the standard pyglet ortho
projection and default OpenGL environment to simplify things and not confuse
the message of the example. The following is a proposed replacement for the
example:
from pyglet.gl import *
from pyglet import window
from pyglet import clock
def draw(w):
glClear(GL_COLOR_BUFFER_BIT)
glLoadIdentity()
glTranslatef(w.width/2, w.height/2, 0)
glRotatef(r, 0, 0, 1)
glBegin(GL_QUADS)
glVertex2f(-w.width/4, -w.width/4)
glVertex2f(-w.width/4, w.width/4)
glVertex2f(w.width/4, w.width/4)
glVertex2f(w.width/4, -w.width/4)
glEnd()
w1 = window.Window(200, 200, caption='First window')
w2 = window.Window(300, 300, caption='Second window')
r = 0
clock.set_fps_limit(30)
while not (w1.has_exit or w2.has_exit):
dt = clock.tick()
r += 1
if r > 360: r = 0
w1.switch_to()
w1.dispatch_events()
draw(w1)
w1.flip()
w2.switch_to()
w2.dispatch_events()
draw(w2)
w2.flip()
Richard
On 8/20/07, André <[EMAIL PROTECTED]> wrote:
>
>
> Hi-
>
> I just downloaded pyglet and am not familiar at all with OpenGL. I
> tried various examples and looked at the code and am a bit confused by
> multiple_windows.py and believe I found a bug - by comparing with the
> code in opengl.py. As the code was written, it only displayed two
> blank (white) windows. Here's how I changed it so that it did what I
> assumed to be the desired behaviour:
>
> # no change in code above while loop
>
> while not (w1.has_exit or w2.has_exit):
> dt = clock.tick()
> r += 1
> if r > 360: r = 0
>
> w1.switch_to()
> w1.dispatch_events()
> setup() # added this
> draw()
> w1.flip()
>
> w2.switch_to()
> w2.dispatch_events()
> setup() # added this
> draw()
> w2.flip()
>
> ########
> 1. Is this correct?
> 2. Have these examples been adapted from some newbie friendly
> tutorials on OpenGL that I could refer to?
>
> Cheers,
>
> André
>
> P.S. pyglet version 1.0alpha2 on a Mac with Python 2.5
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---