Python PyOpenGL非常慢
我的问题是,我的程序显示一个限制为120 fps的简单立方体,但只能以25 fps的速度运行。我发现所有的性能损失都在OpenGL部分,但我不知道具体在哪里 我的问题是:Python PyOpenGL非常慢,python,performance,opengl,Python,Performance,Opengl,我的问题是,我的程序显示一个限制为120 fps的简单立方体,但只能以25 fps的速度运行。我发现所有的性能损失都在OpenGL部分,但我不知道具体在哪里 我的问题是: OpenGL在Python中运行那么慢是正常的吗 我的旧笔记本是问题的一部分吗 下面是我用来显示多维数据集的代码: def draw(self): glBegin(GL_QUADS)#info for OGL: treat following code as surface drawing code for
- OpenGL在Python中运行那么慢是正常的吗
- 我的旧笔记本是问题的一部分吗
def draw(self):
glBegin(GL_QUADS)#info for OGL: treat following code as surface drawing code
for surface in self.surfaces:
x = 0
for vertex in surface:
x+=1
glColor3fv(self.colors[x])
glVertex3fv(self.verticles[vertex])
glEnd()
glBegin(GL_LINES) #info for OGL: treat following code as line drawing code
for edge in self.edges:
for vertex in edge:
glVertex3fv(self.verticles[vertex]) #pass each verticle in the verticles list to glVertex3fv, which creates edges
glEnd() #info for OGL:no more code incoming
不,OpenGL运行那么慢是不正常的。这里的缓慢来自于使用即时模式(glBegin(),glEnd())。基本上,您一个接一个地调用这些python命令的每一帧,卡都必须立即生成输出。这在C语言中很慢,更不用说Python了,它正在逐行解释 您要做的是事先准备顶点缓冲区(通常称为VBO),然后在渲染时提交它们以进行批渲染 看看这本wikibook for modern OpenGL(>=2.0)方法:。它是用C/C++编写的,但是您可以遵循函数调用和原则