Are Vertex Array Objects supported in Android OpenGL ES 2.0 using extensions?

后端 未结 1 1782
一向
一向 2020-12-19 11:58

I\'m trying to write some code that uses VAOs in C++ using the Android NDK to compile. I expect to be able to use glDeleteVertexArraysOES, glGenVertexArra

相关标签:
1条回答
  • 2020-12-19 12:45

    The GLES2 library that gets included with NDK may only include the standard OpenGL ES 2.0 calls, without any extensions that may or may not be supported by each particular device/manufacturer/driver...

    While most new devices support VAO, you may have to get the pointers to the functions yourself, or get a different binary library (you can extract it from your device, or from some ROM).

    I had to resort to using this code to get the function pointers from the dylib:

    //these ugly typenames are defined in GLES2/gl2ext.h
    PFNGLBINDVERTEXARRAYOESPROC bindVertexArrayOES;
    PFNGLDELETEVERTEXARRAYSOESPROC deleteVertexArraysOES;
    PFNGLGENVERTEXARRAYSOESPROC genVertexArraysOES;
    PFNGLISVERTEXARRAYOESPROC isVertexArrayOES;
    
    void initialiseFunctions () {
    
    //[check here that VAOs are actually supported]
    
    void *libhandle = dlopen("libGLESv2.so", RTLD_LAZY);
    
    bindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC) dlsym(libhandle,
                                                             "glBindVertexArrayOES");
    deleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC) dlsym(libhandle,
                                                                   "glDeleteVertexArraysOES");
    genVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)dlsym(libhandle,
                                                            "glGenVertexArraysOES");
    isVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC)dlsym(libhandle,
                                                        "glIsVertexArrayOES");
    
    [...]
    }
    

    I define these function pointers inside a static object. There may be better ways of doing it, but this has worked for me so far.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题