简体   繁体   中英

Pyglet 2d Camera OpenGL

It is not much information out there how to do a 2d camera in Pyglet. I assume its not a good idea to move all sprites so I look for something similar to a Surface in Pygame that I could move instead. But the is no such thing in Pyglet? Is this the way it should be done in openGl? or am I missing something important? I don't know what the gl command do but it is working.

def on_draw(self):
    #camera start

    glMatrixMode(gl.GL_PROJECTION)
    glLoadIdentity()
    glOrtho(self.camera.x, self.camera.x2, self.camera.y, self.camera.y2, -1, 1)

    #camera end
    self.clear()
    self.batch.draw()# draw stuff

pyglet/examples 文件夹中有一个相机示例: https : //github.com/pyglet/pyglet/blob/pyglet-1.5-maintenance/examples/window/camera.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM