我正在尝试提高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之间更改displayType。我目前的点数大约为28FPS,三角形只有大约5-6FPS。我这个差异正常吗?我该怎么做才能改善FPS?
答案 0 :(得分:0)
由于您正在使用顶点缓冲区对象,因此您不受CPU限制。所以要么你有很多几何,要么你实际上没有硬件加速。无论哪种方式,由于更高的填充率要求,预计从点到填充三角形的性能切换减少。