hi, up to now I've used pyglet just for 2D stuff with hardly any OpenGL. What I'd like to do is tilt the plane on which my 2D sprites are drawn. I don't know if I'm thinking of this correctly in relation to OpenGL, but if a normal projection has the player looking straight on at the picture plane, I'd like to rotate that angle made between the projection and the picture plane, so the perspective is 'tilted' (sorry if I'm getting terms wrong here!).

I'm guessing I can't just 'tilt' the 2D plane, whatever that means, since the 2D sprites would disappear. However if it's easier to do that with 3D sprites I'm open to that.

Here's what I'm doing so far:

* create a group to set OpenGL state for sprites

class CustomGroup(pyglet.graphics.Group):
    def set_state(self):
        glLoadIdentity()
        glRotatef(0.0, 1.0, 0.0, 0.0)
        glRotatef(0.0, 0.0, 1.0, 0.0)
        glTranslatef(0.0, 0.0, 0.0)

    def unset_state(self):
        pass

(Though, if I try to rotate about a vector with glRotate, since the sprites are just 2D the effect isn't what I want as expected).

* load images and make sprites, assigning to a batch and setting the group to an instance of the class above

* in on_draw

def on_draw():
    window.clear()
    batch.draw()


I've tried giving the window a new on_resize, since as I understand it the default is just a 2D projection (which I think I don't want, I'm not sure), using this code from a nehe example:

def resize(width, height):
    if height==0:
        height=1
    glViewport(0, 0, width, height)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(45, 1.0*width/height, 0.1, 100.0)
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()

I think this is basically what I want; from what I understand the gluPerspective call sets the perspective angle at 45 degrees. However setting this to the on_resize of the window then doesn't show my batch.

In the same example the code also translates to z = -5.0, but doing the same thing in my code (without the new resize) also hides the batch. I'm guessing that's because of the default projection? However it doesn't seem to help to add the new resize.

Any further advice or pointers?



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