Your window resize handler needs to return EVENT_HANDLED to prevent the default handler (which will reset to the default orthographic projection) from running.
On Sun, Aug 2, 2009 at 7:46 PM, Richard Tew <[email protected]> wrote: > > Hi, > > I have been playing around with a simple script I wrote some time back > in 2007 to visualise a grid of lines using OpenGL. It used to work > fine, but with the current version of Pyglet, it no longer does. > > I use gluLookAt to do my camera, and when I tried the script again > yesterday, I could not see the badly lit array of lines. I assumed > that the problem was with the view the camera calculated, or my grid > and played around with it for quite a few hours rewriting the camera > and in general trying to get anything to display with gluLookAt. > > The pattern I originally used was to initialise the projection in the > Window resize handler, which gets called once on application startup. > > @w.event > def on_resize(width, height): > # Override the default on_resize handler to create a 3D projection > glViewport(0, 0, width, height) > glMatrixMode(GL_PROJECTION) > glLoadIdentity() > gluPerspective(60.0, width / float(height), 0.1, 1000.0) > glMatrixMode(GL_MODELVIEW) > > Then in my main loop, I called gluLookAt. > > glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) > > glLoadIdentity() > > view = camera.GetView() > gluLookAt(camera.position.x, camera.position.y, camera.position.z, > view.x, view.y, view.z, > camera.up.x, camera.up.y, camera.up.z) > > Eventually, on a whim I copied the logic out of on_resize and pasted > it above the gluLookAt code. This fixed the problem. > > Is it possible that something in Pyglet is requiring me to do the > projection mode work every loop? > > You can check out the hacked to work script here: > > http://pastebin.com/m16c7e31c > > Cheers, > Richard. > > > > -- Tristam MacDonald http://swiftcoder.wordpress.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
