[英]Pyglet 2d Camera OpenGL
It is not much information out there how to do a 2d camera in Pyglet.关于如何在 Pyglet 中制作 2d 相机的信息并不多。 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.
我认为移动所有精灵不是一个好主意,所以我在 Pygame 中寻找类似于 Surface 的东西,我可以移动它。 But the is no such thing in Pyglet?
但是 Pyglet 中没有这样的东西吗? Is this the way it should be done in openGl?
这是应该在openGl中完成的方式吗? or am I missing something important?
还是我错过了一些重要的东西? I don't know what the gl command do but it is working.
我不知道 gl 命令做什么,但它正在工作。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.