user1299518
user1299518

Reputation:

Android - OpenGL ES and use of glMapBufferOES / glUnmapBufferOES

I'm trying to convert my glGetBufferSubData calls into Android OpenGL ES and i can't find a way to do it. For example, i added this:

#define GL_GLEXT_PROTOTYPES      <---
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
...

which supposedly includes the xOES functions and therefore glMapBufferOES and glUnmapBufferOES. Indeed, these functions are found and compiled normally, yet my APK crashes. I then decided to get them by pointers like this:

PFNGLMAPBUFFEROESPROC glMapBufferOES = NULL;
PFNGLUNMAPBUFFEROESPROC glUnmapBufferOES = NULL;

...

glMapBufferOES = (PFNGLMAPBUFFEROESPROC) eglGetProcAddress("glMapBufferOES");
glUnmapBufferOES = (PFNGLUNMAPBUFFEROESPROC) eglGetProcAddress("glUnmapBufferOES");

...

if (glMapBufferOES && glUnmapBufferOES) {
   vector<float> v(buffer_size);
   float* mv = (float*)glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
   memcpy(&v[0], &mv[0], buffer_size * sizeof(float));
   glUnmapBufferOES(GL_ARRAY_BUFFER);
}

Yet once again my reward is a crash (the GL_WRITE_ONLY_OES above is not a typo; in fact GL_READ_ONLY_OES is simply absent). I'm not trying to use glGetBufferSubDataOES since there's not a single GL_x_vertex_buffer_object extension on my Android 4.4.4 KitKat. I'm using Genymotion. Is there any obvious error on my side or a specific extension to check against glMapBufferOES ?

Upvotes: 1

Views: 2928

Answers (1)

Reto Koradi
Reto Koradi

Reputation: 54592

The extension you need to check for is GL_OES_mapbuffer. If that shows up in the result of glGetString(GL_EXTENSIONS), your device supports the extension.

Upvotes: 1

Related Questions