diff --git a/common/cogl-mesh.c b/common/cogl-mesh.c index 16a4db16a..5b35463ea 100644 --- a/common/cogl-mesh.c +++ b/common/cogl-mesh.c @@ -196,11 +196,18 @@ #endif #ifndef HAVE_COGL_GL + /* GLES doesn't have glDrawRangeElements, so we simply pretend it does * but that it makes no use of the start, end constraints: */ #define glDrawRangeElements(mode, start, end, count, type, indices) \ glDrawElements (mode, count, type, indices) -#endif + +#else /* HAVE_COGL_GL */ + +#define glDrawRangeElements(mode, start, end, count, type, indices) \ + ctx->pf_glDrawRangeElements (mode, start, end, count, type, indices) + +#endif /* HAVE_COGL_GL */ static void _cogl_mesh_free (CoglMesh *mesh); @@ -1588,6 +1595,8 @@ cogl_mesh_draw_range_elements (CoglHandle handle, const GLvoid *indices) { CoglMesh *mesh; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); if (!cogl_is_mesh (handle)) return; diff --git a/gl/cogl-context.c b/gl/cogl-context.c index 09051628b..a9240a102 100644 --- a/gl/cogl-context.c +++ b/gl/cogl-context.c @@ -114,6 +114,8 @@ cogl_create_context () _context->pf_glUniformMatrix2fvARB = NULL; _context->pf_glUniformMatrix3fvARB = NULL; _context->pf_glUniformMatrix4fvARB = NULL; + + _context->pf_glDrawRangeElements = NULL; /* Init OpenGL state */ GE( glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ); diff --git a/gl/cogl-context.h b/gl/cogl-context.h index f68ef5606..5ab583862 100644 --- a/gl/cogl-context.h +++ b/gl/cogl-context.h @@ -137,6 +137,8 @@ typedef struct COGL_PFNGLUNIFORMMATRIX2FVARBPROC pf_glUniformMatrix2fvARB; COGL_PFNGLUNIFORMMATRIX3FVARBPROC pf_glUniformMatrix3fvARB; COGL_PFNGLUNIFORMMATRIX4FVARBPROC pf_glUniformMatrix4fvARB; + + COGL_PFNGLDRAWRANGEELEMENTSPROC pf_glDrawRangeElements; } CoglContext; CoglContext * diff --git a/gl/cogl-defines.h.in b/gl/cogl-defines.h.in index 31c75bbb2..8658bed46 100644 --- a/gl/cogl-defines.h.in +++ b/gl/cogl-defines.h.in @@ -1013,6 +1013,15 @@ typedef void GLboolean transpose, const GLfloat *value); +typedef void + (APIENTRYP COGL_PFNGLDRAWRANGEELEMENTSPROC) + (GLenum mode, + GLuint start, + GLuint end, + GLsizei count, + GLenum type, + const GLvoid *indices); + G_END_DECLS #endif diff --git a/gl/cogl.c b/gl/cogl.c index 908a57c30..1ce1a3c82 100644 --- a/gl/cogl.c +++ b/gl/cogl.c @@ -1256,6 +1256,13 @@ _cogl_features_init () flags |= COGL_FEATURE_VBOS; } + /* This should always be available because it is defined in GL 1.2, + but we can't call it directly because under Windows functions > + 1.1 aren't exported */ + ctx->pf_glDrawRangeElements = + (COGL_PFNGLDRAWRANGEELEMENTSPROC) + cogl_get_proc_address ("glDrawRangeElements"); + /* Cache features */ ctx->feature_flags = flags; ctx->features_cached = TRUE;