PyOpenGL FPS 改进

发布于 2024-11-08 11:37:43 字数 1399 浏览 3 评论 0原文

我正在尝试提高 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸 2024-11-15 11:37:43

由于您使用的是顶点缓冲区对象,因此您不受 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文