undefined reference glBindVertexArrayOES,glGenVertexArraysOES,glDeleteVertexArraysOES in eclipse

独自空忆成欢 提交于 2019-12-07 11:22:17

问题


Trying to compile C++ code with Android NDK but these errors wont go away

undefined reference to glBindVertexArrayOES
undefined reference to glGenVertexArraysOES
undefined reference to glDeleteVertexArraysOES 

In .mk file wrote

LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz  -landroid -lEGL

All other function are found perfectly, do i need to declare anything to make these work?


回答1:


This functions are not in base opengl es specification, so they are not defined by default, but offered as extensions.

If the device you use supports this extension, you can get the phsical address of the functions and use it by a function pointer.

it should be looking like this:

PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES;
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOES;
PFNGLISVERTEXARRAYOESPROC glIsVertexArrayOES;

glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress ( "glGenVertexArraysOES" );
glBindVertexArrayOES = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress ( "glBindVertexArrayOES" );
glDeleteVertexArraysOES = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress ( "glDeleteVertexArraysOES" );
glIsVertexArrayOES = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress ( "glIsVertexArrayOES" );

than you can use the functions. Just not forget this binding happens on runtime, so checking if this functions are supported is a good idea. If device does not support, the pointers will be 0.



来源:https://stackoverflow.com/questions/14406829/undefined-reference-glbindvertexarrayoes-glgenvertexarraysoes-gldeletevertexarra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!