Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve VBO rendering efficiency #1207

Open
wants to merge 1 commit into
base: SteamEngine
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cura/gui/util/openglHelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ def __init__(self, renderType, vertexArray, normalArray = None, indicesArray = N

def render(self):
glEnableClientState(GL_VERTEX_ARRAY)
if self._hasNormals:
glEnableClientState(GL_NORMAL_ARRAY)
if self._buffers is None:
glVertexPointer(3, GL_FLOAT, 0, self._vertexArray)
if self._hasNormals:
glEnableClientState(GL_NORMAL_ARRAY)
glNormalPointer(GL_FLOAT, 0, self._normalArray)
if self._hasIndices:
glDrawElements(self._renderType, self._size, GL_UNSIGNED_INT, self._indicesArray)
Expand All @@ -193,23 +194,23 @@ def render(self):
glDrawArrays(self._renderType, i * batchSize, batchSize)
glDrawArrays(self._renderType, extraStartPos, extraCount)
else:
if self._hasIndices:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self._bufferIndices)
for info in self._buffers:
glBindBuffer(GL_ARRAY_BUFFER, info['buffer'])
if self._hasNormals:
glEnableClientState(GL_NORMAL_ARRAY)
glVertexPointer(3, GL_FLOAT, 2*3*4, c_void_p(0))
glNormalPointer(GL_FLOAT, 2*3*4, c_void_p(3 * 4))
else:
glVertexPointer(3, GL_FLOAT, 3*4, c_void_p(0))
if self._hasIndices:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self._bufferIndices)
glDrawElements(self._renderType, self._size, GL_UNSIGNED_INT, c_void_p(0))
else:
glDrawArrays(self._renderType, 0, info['size'])

glBindBuffer(GL_ARRAY_BUFFER, 0)
if self._hasIndices:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)
glBindBuffer(GL_ARRAY_BUFFER, 0)
if self._hasIndices:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)

glDisableClientState(GL_VERTEX_ARRAY)
if self._hasNormals:
Expand Down