我想画一个有线条的立方体
这是我的密码。它给了我一个白色的框架,里面什么都没有。什么也没发生。我做错了什么?这是调用函数的顺序有问题还是投影有问题
def myInit():
glClearColor(0.0, 0.0, 0.0, 1.0)
glColor3f(0.2, 0.5, 0.4)
gluPerspective(45, 1.33, 0.1, 50.0)
vertices= (
(100, -100, -100),
(100, 100, -100),
(-100, 100, -100),
(-100, -100, -100),
(100, -100, 100),
(100, 100, 100),
(-100, -100, 100),
(-100, 100, 100)
)
edges = (
(0,1),
(0,3),
(0,4),
(2,1),
(2,3),
(2,7),
(6,3),
(6,4),
(6,7),
(5,1),
(5,4),
(5,7)
)
def Display():
glBegin(GL_LINES)
for edge in edges:
for vertex in edge:
glVertex3fv(vertices[vertex])
glEnd()
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(800, 600)
myInit()
glutDisplayFunc(Display)
glutMainLoop()
所有不在Viewing frustum中的几何体都将被剪裁。多维数据集的大小为200x200x200。您必须创建一个足够大的视锥
例如,设置远平面为1000.0的透视投影矩阵^{} 。投影矩阵旨在设置为当前投影矩阵(} :
GL_PROJECTION
)。见^{通过^{} 清除每个帧中的显示:
通过} 持续更新显示
glutSwapBuffers
交换当前双缓冲窗口的缓冲区,并通过调用^{另见Immediate mode and legacy OpenGL
请参见示例:
相关问题 更多 >
编程相关推荐