diff --git a/src/graphics/gl_headers.hpp b/src/graphics/gl_headers.hpp index 779d2ae47..951b70066 100644 --- a/src/graphics/gl_headers.hpp +++ b/src/graphics/gl_headers.hpp @@ -62,6 +62,8 @@ extern "C" { #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE extern PFNGLDEBUGMESSAGECALLBACKKHRPROC pglDebugMessageCallbackKHR; +extern PFNGLDRAWELEMENTSBASEVERTEXOESPROC pglDrawElementsBaseVertexOES; +#define glDrawElementsBaseVertex pglDrawElementsBaseVertexOES #define glDebugMessageCallbackARB pglDebugMessageCallbackKHR #endif diff --git a/src/graphics/glwrap.cpp b/src/graphics/glwrap.cpp index 888bc854b..d0a4abd1c 100644 --- a/src/graphics/glwrap.cpp +++ b/src/graphics/glwrap.cpp @@ -34,6 +34,7 @@ #include #include +PFNGLDRAWELEMENTSBASEVERTEXOESPROC pglDrawElementsBaseVertexOES = 0; PFNGLDEBUGMESSAGECALLBACKKHRPROC pglDebugMessageCallbackKHR = 0; #endif @@ -192,6 +193,7 @@ void initGL() if (GLEW_OK != err) Log::fatal("GLEW", "Glew initialisation failed with error %s", glewGetErrorString(err)); #else + glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXOESPROC)eglGetProcAddress("glDrawElementsBaseVertexOES"); glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKKHRPROC)eglGetProcAddress("glDebugMessageCallbackKHR"); #endif diff --git a/src/graphics/render_geometry.cpp b/src/graphics/render_geometry.cpp index 87c3a6fc3..5456b706b 100644 --- a/src/graphics/render_geometry.cpp +++ b/src/graphics/render_geometry.cpp @@ -989,9 +989,9 @@ void draw(const T *Shader, const GLMesh *mesh, uniforms... Args) } Shader->setUniforms(Args...); - glDrawRangeElements(ptype, (int)mesh->vaoBaseVertex, - (int)mesh->vaoBaseVertex + count - 1, - count, itype, (GLvoid *)mesh->vaoOffset); + glDrawElementsBaseVertex(ptype, (int)count, itype, + (GLvoid *)mesh->vaoOffset, + (int)mesh->vaoBaseVertex); if (need_change_hue) { @@ -1645,9 +1645,8 @@ void IrrDriver::renderTransparent() DisplaceMaskShader::getInstance()->use(); DisplaceMaskShader::getInstance()->setUniforms(AbsoluteTransformation); - glDrawRangeElements(ptype, (int)mesh.vaoBaseVertex, - (int)mesh.vaoBaseVertex + count - 1, - count, itype, (GLvoid *)mesh.vaoOffset); + glDrawElementsBaseVertex(ptype, (int)count, itype, + (GLvoid *)mesh.vaoOffset, (int)mesh.vaoBaseVertex); } irr_driver->getFBO(FBO_DISPLACE).bind(); @@ -1678,9 +1677,8 @@ void IrrDriver::renderTransparent() core::vector2df(cb->getDirX(), cb->getDirY()), core::vector2df(cb->getDir2X(), cb->getDir2Y())); - glDrawRangeElements(ptype, (int)mesh.vaoBaseVertex, - (int)mesh.vaoBaseVertex + count - 1, - count, itype, (GLvoid *)mesh.vaoOffset); + glDrawElementsBaseVertex(ptype, (int)count, itype, (GLvoid *)mesh.vaoOffset, + (int)mesh.vaoBaseVertex); } irr_driver->getFBO(FBO_COLORS).bind(); @@ -1702,9 +1700,8 @@ void drawShadow(const T *Shader, unsigned cascade, const GLMesh *mesh, uniforms. size_t count = mesh->IndexCount; Shader->setUniforms(cascade, Args...); - glDrawRangeElements(ptype, (int)mesh->vaoBaseVertex, - (int)mesh->vaoBaseVertex + count - 1, - count, itype, (GLvoid *)mesh->vaoOffset); + glDrawElementsBaseVertex(ptype, (int)count, itype, + (GLvoid *)mesh->vaoOffset, (int)mesh->vaoBaseVertex); } // drawShadow // ---------------------------------------------------------------------------- diff --git a/src/graphics/stk_mesh_scene_node.cpp b/src/graphics/stk_mesh_scene_node.cpp index 9a6f337c4..cc725de0f 100644 --- a/src/graphics/stk_mesh_scene_node.cpp +++ b/src/graphics/stk_mesh_scene_node.cpp @@ -136,9 +136,7 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh) GLenum itype = mesh.IndexType; size_t count = mesh.IndexCount; ColorizeShader::getInstance()->setUniforms(AbsoluteTransformation, video::SColorf(glowcolor.getRed() / 255.f, glowcolor.getGreen() / 255.f, glowcolor.getBlue() / 255.f)); - glDrawRangeElements(ptype, (int)mesh.vaoBaseVertex, - (int)mesh.vaoBaseVertex + count - 1, - count, itype, (GLvoid *)mesh.vaoOffset); + glDrawElementsBaseVertex(ptype, count, itype, (GLvoid *)mesh.vaoOffset, mesh.vaoBaseVertex); } void STKMeshSceneNode::updatevbo()