def set_3d(self, size):
"""Configure OpenGL to draw in 3d."""
width, height = size
GL.glEnable(GL.GL_DEPTH_TEST)
GL.glViewport(0, 0, width, height)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.gluPerspective(65.0, width / float(height), 0.1, 60.0)
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
x, y = self.player.rotation
GL.glRotatef(x, 0, 1, 0)
GL.glRotatef(-y, math.cos(math.radians(x)), 0, math.sin(math.radians(x)))
x, y, z = self.player.position
GL.glTranslatef(-x, -y, -z)
评论列表
文章目录