self.window = pyglet.window.Window(640, 480)
This will setup a 2D orthographic projection by default, obviously a
sphere is 3D, which is why you can't see it. You need to setup a 3D
projection. Which you can do with something like this:
glViewport(0, 0, self.window.width, self.window.height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(70, 1.0*self.window.width/self.window.height, 0.1, 1000.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
This sets up a perspective projection, you can also setup a 3D ortho
projection if you don't want foreshortening. Use glOrtho for that.
If you make your window resizeable put the above code in an
on_resize(width, height) handler method on the window.
hth,
-Casey
On Wed, Jul 8, 2009 at 6:49 AM, Dag Henrik<[email protected]> wrote:
>
> Hello! I am trying out pyglet, and I would like to draw a sphere.
>
> Here's some code that I'm trying to use right now:
>
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
>
> import math
> from pyglet.gl import *
>
> class Viewer:
> """Display self-organizing map."""
> def __init__(self, n_neurons):
> self.window = pyglet.window.Window(640, 480)
> self.n_neurons = n_neurons
> self.window.push_handlers(self)
>
> def on_draw(self):
> """Continuously updated."""
> glClear(GL_COLOR_BUFFER_BIT)
> glLoadIdentity()
>
> sphere = gluNewQuadric()
> gluSphere(sphere, 1.0, 100, 100)
>
> if __name__ == "__main__":
> v = Viewer(10)
> pyglet.app.run()
>
> It shows a black background, but without any sphere. I am able to draw
> other
> primitive creatures though, such as GL_LINES_LOOP etc.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---