PyOpenGL FPS 改进
我正在尝试提高 python OpenGL 程序的 FPS 速率。到目前为止,我的方法是:
self.bufferVertices = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
glBufferData(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(vertices), ADT.voidDataPointer(vertices), GL_STATIC_DRAW_ARB)
self.bufferNormals = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferNormals)
glBufferData(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(normals), ADT.voidDataPointer(normals), GL_STATIC_DRAW_ARB)
self.size = len(triangles)
self.bufferTriangles = glGenBuffers(1)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, self.bufferTriangles)
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, len(triangles), ADT.voidDataPointer(triangles), GL_STATIC_DRAW_ARB)
-----------------------------------------------------------------
glEnableClientState(GL_VERTEX_ARRAY)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
glVertexPointer(3, GL_FLOAT, 0, None)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferNormals)
glNormalPointer(GL_FLOAT, 0, None)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, self.bufferTriangles)
glIndexPointer(GL_INT, 0, None)
glDrawElements(displayType, self.size, GL_UNSIGNED_INT, 0)
glDisableClientState(GL_VERTEX_ARRAY)
现在显示类型在 GL_POINTS 和 GL_TRIANGLES 之间更改。我目前对于点的帧率大约为 28FPS,对于三角形的帧率只有大约 5-6FPS。我这种差异正常吗?我可以做什么来提高 FPS?
I'm trying to improve my FPS rate for an python OpenGL program. So far my approach is:
self.bufferVertices = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
glBufferData(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(vertices), ADT.voidDataPointer(vertices), GL_STATIC_DRAW_ARB)
self.bufferNormals = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferNormals)
glBufferData(GL_ARRAY_BUFFER_ARB, ADT.arrayByteCount(normals), ADT.voidDataPointer(normals), GL_STATIC_DRAW_ARB)
self.size = len(triangles)
self.bufferTriangles = glGenBuffers(1)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, self.bufferTriangles)
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, len(triangles), ADT.voidDataPointer(triangles), GL_STATIC_DRAW_ARB)
-----------------------------------------------------------------
glEnableClientState(GL_VERTEX_ARRAY)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferVertices)
glVertexPointer(3, GL_FLOAT, 0, None)
glBindBuffer(GL_ARRAY_BUFFER_ARB, self.bufferNormals)
glNormalPointer(GL_FLOAT, 0, None)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, self.bufferTriangles)
glIndexPointer(GL_INT, 0, None)
glDrawElements(displayType, self.size, GL_UNSIGNED_INT, 0)
glDisableClientState(GL_VERTEX_ARRAY)
Now displayType is changed between GL_POINTS and GL_TRIANGLES. I'm currently getting about 28FPS for points and only about 5-6FPS for triangles. I this difference normal ? What can I do to improve the FPS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您使用的是顶点缓冲区对象,因此您不受 CPU 限制。所以要么你有很多几何体,要么你实际上没有获得硬件加速。无论哪种方式,由于填充率要求较高,从点切换到填充三角形的性能都会下降。
Since you're using vertex buffer objects you're not CPU limited. So either you have a lot of geometry, or you're not actually got HW acceleration. Either way a decrease in performance switching from points to filled triangles is to be expected, due to higher fillrate demands.