@@ -230,8 +230,10 @@ void ofGLProgrammableRenderer::draw(const ofVboMesh & mesh, ofPolyRenderMode ren
230230void ofGLProgrammableRenderer::drawInstanced (const ofVboMesh & mesh, ofPolyRenderMode renderType, int primCount) const {
231231 if (mesh.getNumVertices () == 0 ) return ;
232232 GLuint mode = ofGetGLPrimitiveMode (mesh.getMode ());
233- #ifndef TARGET_OPENGLES
233+ #if !defined( TARGET_OPENGLES ) || defined(TARGET_EMSCRIPTEN)
234+ #if !defined(TARGET_EMSCRIPTEN)
234235 glPolygonMode (GL_FRONT_AND_BACK, ofGetGLPolyMode (renderType));
236+ #endif
235237 if (mesh.getNumIndices () && renderType != OF_MESH_POINTS) {
236238 if (primCount <= 1 ) {
237239 drawElements (mesh.getVbo (), mode, mesh.getNumIndices ());
@@ -251,8 +253,9 @@ void ofGLProgrammableRenderer::drawInstanced(const ofVboMesh & mesh, ofPolyRende
251253 // after we're finished drawing, following the principle of least surprise.
252254 // ideally the glPolygonMode (or the polygon draw mode) should be part of ofStyle so that we can keep track
253255 // of its state on the client side...
254-
256+ # if !defined(TARGET_EMSCRIPTEN)
255257 glPolygonMode (GL_FRONT_AND_BACK, currentStyle.bFill ? GL_FILL : GL_LINE);
258+ #endif
256259#else
257260 if (renderType == OF_MESH_POINTS) {
258261 draw (mesh.getVbo (), GL_POINTS, 0 , mesh.getNumVertices ());
@@ -464,14 +467,18 @@ void ofGLProgrammableRenderer::drawElementsInstanced(const ofVbo & vbo, GLuint d
464467 if (vbo.getUsingVerts ()) {
465468 vbo.bind ();
466469 const_cast <ofGLProgrammableRenderer *>(this )->setAttributes (vbo.getUsingVerts (), vbo.getUsingColors (), vbo.getUsingTexCoords (), vbo.getUsingNormals ());
467- #ifdef TARGET_OPENGLES
470+ #if defined( TARGET_OPENGLES) && !defined(TARGET_EMSCRIPTEN) // TODO: Check against OPENGL_ES Version
468471 // todo: activate instancing once OPENGL ES supports instancing, starting with version 3.0
469472 // unfortunately there is currently no easy way within oF to query the current OpenGL version.
470473 // https://www.khronos.org/opengles/sdk/docs/man3/xhtml/glDrawElementsInstanced.xml
471474 ofLogWarning (" ofVbo" ) << " drawElementsInstanced(): hardware instancing is not supported on OpenGL ES < 3.0" ;
472475 // glDrawElementsInstanced(drawMode, amt, GL_UNSIGNED_SHORT, nullptr, primCount);
473476#else
477+ #if defined(TARGET_OPENGLES)
478+ glDrawElementsInstanced (drawMode, amt, GL_UNSIGNED_SHORT, nullptr , primCount);
479+ #else
474480 glDrawElementsInstanced (drawMode, amt, GL_UNSIGNED_INT, nullptr , primCount);
481+ #endif
475482#endif
476483 vbo.unbind ();
477484 }
0 commit comments