# to glMapBufferOES or not to glMapBufferOES

**URL:** https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262
**Category:** PowerVR Insider
**Created:** [December 12, 2011, 2:29pm UTC](https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262 "2011-12-12T14:29:33Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)
#### Post date: [December 12, 2011, 2:29pm UTC](https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262/1 "2011-12-12T14:29:33Z")

</div>

Hi,  
  
  
  
  
  
In PVRTgles2Ext.cpp there is this code

* * *
  
  
  
#if !defined(TARGET\_OS\_IPHONE)  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/\* GL\_EXT\_multi\_draw\_arrays \*/  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (strstr((char \*)pszGLExtensions, "GL\_EXT\_multi\_draw\_arrays"))  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTS) PVRGetProcAddress(glMultiDrawElementsEXT);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYS) PVRGetProcAddress(glMultiDrawArraysEXT);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/\* GL\_EXT\_multi\_draw\_arrays \*/  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (strstr((char \*)pszGLExtensions, "GL\_OES\_mapbuffer"))  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glMapBufferOES = (PFNGLMAPBUFFEROES) PVRGetProcAddress(glMapBufferOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glUnmapBufferOES = (PFNGLUNMAPBUFFEROES) PVRGetProcAddress(glUnmapBufferOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glGetBufferPointervOES = (PFNGLGETBUFFERPOINTERVOES) PVRGetProcAddress(glGetBufferPointervOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
  
  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/\* GL\_OES\_vertex\_array\_object \*/  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (strstr((char \*)pszGLExtensions, "GL\_OES\_vertex\_array\_object"))  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOES) PVRGetProcAddress(glBindVertexArrayOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOES) PVRGetProcAddress(glDeleteVertexArraysOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOES) PVRGetProcAddress(glGenVertexArraysOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;glIsVertexArrayOES = (PFNGLISVERTEXARRAYOES) PVRGetProcAddress(glIsVertexArrayOES);  
  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
  
#endif  
  
  
  

* * *
  
  
  
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 ???

---

<div class="post-metadata">

### Author: ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)
#### Post date: [December 12, 2011, 3:02pm UTC](https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262/2 "2011-12-12T15:02:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)
#### Post date: [December 12, 2011, 4:33pm UTC](https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262/3 "2011-12-12T16:33:38Z")

</div>

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_

---

<div class="post-metadata">

### Author: ![arron](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arron](https://forums.imgtec.com/u/arron)
#### Post date: [December 13, 2011, 10:43am UTC](https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262/4 "2011-12-13T10:43:16Z")

</div>

Hi.  
  
  
  
  
  
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.  
  
  
  
  
  
i.e:

Code:

  
#ifdef TARGET\_OS\_IPHONE  
&nbsp;&nbsp;&nbsp;void\* pData = glMapBufferOES(GL\_ARRAY\_BUFFER, ...);  
#else  
&nbsp;&nbsp;&nbsp;void\* pData = m\_pExtFunc-\>glMapBufferOES(GL\_ARRAY\_BUFFER, ...);  
#endif  

  
  
  
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

---

<div class="post-metadata">

### Author: ![mkandula](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/mkandula/32/123_2.png) [@mkandula](https://forums.imgtec.com/u/mkandula)
#### Post date: [December 13, 2011, 11:49am UTC](https://forums.imgtec.com/t/to-glmapbufferoes-or-not-to-glmapbufferoes/1262/5 "2011-12-13T11:49:32Z")

</div>

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