Yes thanks that fixes the problem.

On Dec 5, 2:32 pm, "Alex Holkner" <[EMAIL PROTECTED]> wrote:
> On 12/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > trying to do the nehe tutorial lessons 5 (http://nehe.gamedev.net/data/
> > lessons/lesson.asp?lesson=05) I came up with this, but I only get a
> > black screen:
>
> > from pyglet.gl import *
> > from pyglet import window
>
> > # The OpenGL context is created only when you create a window.  Any
> > calls
> > # to OpenGL before a window is created will fail.
> > win = window.Window(visible=False)
>
> > ...
>
> > glViewport(0, 0, win.width, win.height)
> > glMatrixMode(GL_PROJECTION)
> > glLoadIdentity()
> > gluPerspective(45, win.width/ float(win.height), 0.1, 100)
> > glMatrixMode(GL_MODELVIEW)
> > glLoadIdentity()
>
> > win.set_visible()
> > while not win.has_exit:
> >     win.dispatch_events()
> >     ...
>
> You've fallen into a common trap: the pyglet window sets up an
> orthogonal OpenGL projection in its default on_resize() event handler.
>  This is called during the very first dispatch_events(), so it
> replaces the projection projection matrix that you've set up.
>
> The solution is to set up the projection matrix and viewport in an
> on_resize handler:
>
> @win.event
> def on_resize(width, height):
>     glViewport(0, 0, width, height)
>     glMatrixMode(GL_PROJECTION)
>     ... etc.
>     glMatrixMode(GL_MODELVIEW)
>
> This replaces the current initialisation code you have to set up the
> projection.  As a bonus, your window can now be made resizable, and
> the projection and viewport will be kept up-to-date.
>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to