On 3/28/2010 11:53 PM, Mikael Lind wrote:
don't know why combining the translation with the resize code doesn't
work. Can you post a minimal but complete pyglet script that
reproduces the problem?
I've made a zip of the script below that includes an image, available here:
http://sites.google.com/site/georgekoliver/Home/pyglet_perspective_test.zip?attredirects=0&d=1
The script:
import pyglet
from pyglet.gl import *
def resize(width, height):
if height==0:
height=1
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45, 1.0*width/height, -1.0, 100.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
window = pyglet.window.Window(640, 480)
window.on_resize=resize
batch = pyglet.graphics.Batch()
image = pyglet.image.load('crate.bmp')
crate = pyglet.sprite.Sprite(image, 100, 100, batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
if __name__ == '__main__':
pyglet.app.run()
Commenting out the resize() and the assignment to window.on_resize shows
the image as expected, but including the resize gives me a blank window.
I've modified the gluPerspective slightly from the example I took it
from, where they had:
gluPerspective(45, 1.0*width/height, .1, 100.0)
I changed 0.1 to -1, guessing maybe that pyglet was drawing the batch at
z=0? But obviously that doesn't help (nor does keeping it at 0.1 I
should add).
The nehe example I looked at gives me hope, as it clearly shows the 2D
texture first in a straight-on view (i.e. like a regular 2D ortho
projection) but then 'tilting' in perspective when the code rotates the
cube, though maybe I'm misunderstanding that?
Incidentally that example is available here, it's lesson 07.
http://groups.google.com/group/pyglet-users/web/pyglet%20nehe.zip
--
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.