Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions libs/openFrameworks/gl/ofGLProgrammableRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ void ofGLProgrammableRenderer::drawElements(const ofVbo & vbo, GLuint drawMode,
#ifdef TARGET_OPENGLES
glDrawElements(drawMode, amt, GL_UNSIGNED_SHORT, (void *)(sizeof(ofIndexType) * offsetelements));
#else
glDrawElements(drawMode, amt, GL_UNSIGNED_INT, (void *)(sizeof(ofIndexType) * offsetelements));
// GL index type must match sizeof(ofIndexType) (16-bit on macOS via tess2); see commit message.
glDrawElements(drawMode, amt, sizeof(ofIndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void *)(sizeof(ofIndexType) * offsetelements));
#endif
vbo.unbind();
}
Expand Down Expand Up @@ -610,7 +611,8 @@ void ofGLProgrammableRenderer::drawElementsInstanced(const ofVbo & vbo, GLuint d
#if defined(TARGET_OPENGLES)
glDrawElementsInstanced(drawMode, amt, GL_UNSIGNED_SHORT, nullptr, primCount);
#else
glDrawElementsInstanced(drawMode, amt, GL_UNSIGNED_INT, nullptr, primCount);
// GL index type must match sizeof(ofIndexType); see drawElements above.
glDrawElementsInstanced(drawMode, amt, sizeof(ofIndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, nullptr, primCount);
#endif
#endif
vbo.unbind();
Expand Down
9 changes: 6 additions & 3 deletions libs/openFrameworks/gl/ofGLRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ void ofGLRenderer::draw(const ofMesh & vertexData, ofPolyRenderMode renderType,
#ifdef TARGET_OPENGLES
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(), GL_UNSIGNED_SHORT, vertexData.getIndexPointer());
#else
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(), GL_UNSIGNED_INT, vertexData.getIndexPointer());
// GL index type must match sizeof(ofIndexType); see ofGLProgrammableRenderer::drawElements.
glDrawElements(ofGetGLPrimitiveMode(vertexData.getMode()), vertexData.getNumIndices(), sizeof(ofIndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, vertexData.getIndexPointer());
#endif
} else {
glDrawArrays(ofGetGLPrimitiveMode(vertexData.getMode()), 0, vertexData.getNumVertices());
Expand Down Expand Up @@ -389,7 +390,8 @@ void ofGLRenderer::drawElements(const ofVbo & vbo, GLuint drawMode, int amt, int
#ifdef TARGET_OPENGLES
glDrawElements(drawMode, amt, GL_UNSIGNED_SHORT, (void *)(sizeof(ofIndexType) * offsetelements));
#else
glDrawElements(drawMode, amt, GL_UNSIGNED_INT, (void *)(sizeof(ofIndexType) * offsetelements));
// Index type follows sizeof(ofIndexType); see ofGLProgrammableRenderer::drawElements.
glDrawElements(drawMode, amt, sizeof(ofIndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void *)(sizeof(ofIndexType) * offsetelements));
#endif
vbo.unbind();
}
Expand Down Expand Up @@ -423,7 +425,8 @@ void ofGLRenderer::drawElementsInstanced(const ofVbo & vbo, GLuint drawMode, int
ofLogWarning("ofVbo") << "drawElementsInstanced(): hardware instancing is not supported on OpenGL ES < 3.0";
// glDrawElementsInstanced(drawMode, amt, GL_UNSIGNED_SHORT, nullptr, primCount);
#else
glDrawElementsInstanced(drawMode, amt, GL_UNSIGNED_INT, nullptr, primCount);
// Index type follows sizeof(ofIndexType); see ofGLProgrammableRenderer::drawElements.
glDrawElementsInstanced(drawMode, amt, sizeof(ofIndexType) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, nullptr, primCount);
#endif
vbo.unbind();
}
Expand Down
Loading