to glMapBufferOES or not to glMapBufferOES


In PVRTgles2Ext.cpp there is this code

#if !defined(TARGET_OS_IPHONE)

     /* GL_EXT_multi_draw_arrays */

     if (strstr((char *)pszGLExtensions, "GL_EXT_multi_draw_arrays"))


          glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTS) PVRGetProcAddress(glMultiDrawElementsEXT);

          glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYS) PVRGetProcAddress(glMultiDrawArraysEXT);


     /* GL_EXT_multi_draw_arrays */

     if (strstr((char *)pszGLExtensions, "GL_OES_mapbuffer"))


        glMapBufferOES = (PFNGLMAPBUFFEROES) PVRGetProcAddress(glMapBufferOES);

        glUnmapBufferOES = (PFNGLUNMAPBUFFEROES) PVRGetProcAddress(glUnmapBufferOES);

        glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOES) PVRGetProcAddress(glGetBufferPointervOES);


     /* GL_OES_vertex_array_object */

     if (strstr((char *)pszGLExtensions, "GL_OES_vertex_array_object"))


        glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOES) PVRGetProcAddress(glBindVertexArrayOES);

        glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOES) PVRGetProcAddress(glDeleteVertexArraysOES);

        glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOES) PVRGetProcAddress(glGenVertexArraysOES);

          glIsVertexArrayOES = (PFNGLISVERTEXARRAYOES) PVRGetProcAddress(glIsVertexArrayOES);



I was using this glMapBufferOES in windows emulator and while porting to xcode, I had to define "TARGET_OS_IPHONE". This makes glMapBufferOES unusable now. Can someone please give me clarity if this mapbuffer functionality is usable or not on iPhone and iPad ???


How exactly is the function failing? Do you get a rendering error, or is the function causing a compile failure?

glMapBufferOES basically is NULL because TARGET_OS_IPHONE is defined in xcode (unless I have to expect it to be set to a valid pointer somewhere else !)

If I comment this line out in PVRTgles2Ext.cpp, then PVRGetProcAddress will return a valid glMapBufferOES pointer and my app functions fine in the emulator. I do not like the idea of modifying SDK code and so I ask what the correct way is. Also, I request some samples which use glMapBufferOES so that its useful to know usage of such GL EXT functions.

mkandula2011-12-12 17:37:01


On iOS glMapBufferOES is a core GL function so there is no need to retrieve the function pointer.

If you call glMapBufferOES in your own code without using the extension object, then it will function just fine.



   void* pData = glMapBufferOES(GL_ARRAY_BUFFER, ...);
   void* pData = m_pExtFunc->glMapBufferOES(GL_ARRAY_BUFFER, ...);

That should solve your problem. Obviously make sure you have TARGET_OS_IPHONE defined in your preprocessor section within Xcode build settings. Or you could #ifdef __APPLE__.Arron2011-12-13 11:44:48

Hi Arron,

Thank you very much for the prompt reply. Your post really helped me save a lot of time :))