【发布时间】:2021-10-03 04:34:47
【问题描述】:
我在前面有一个 3d 模型,在背景中有一个图像。我正在尝试按像素移动 3d 模型 (x, y)。但是 glTranslatef 函数将它移到其他一些指标中。
我尝试 glViewport(0, 0, width, height) 然后 glOrtho(x, width, height, y, 0.0, 1.0) 但它使对象
消失。
这是我的代码:
# draw the 3d model
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0.0, width, height, 0.0, 0.0, 1.0)
gluPerspective(45, (width / height), 0.1, 50.0)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
glTranslatef(0, 0, -5)
glEnable(GL_DEPTH_TEST)
# reddering the 3d object
box.render()
【问题讨论】:
-
你为什么使用 glOrtho 和 gluPerspective?
-
我没有使用 glOrtho 试图让 3d 消失。如果我删除 gluPerspective 3d 永远不会出现
-
我是 opengl 的新手,我想我现在可以做什么
gluPerspective了。 -
你知道越远的东西越小,所以物体越远你的运动也越小?
-
是的。但我想按像素移动它。我想知道
glTranslatef(x,,y) 值和像素值之间的关系
标签: python opengl pygame pyopengl