user1610950
user1610950

Reputation: 1917

opengles2 glGenVertexArrays ... glGenVertexArraysOES

I am having a bit of trouble sorting this out. I build my SDL opengl app with cmake on mac os x 10.9 it works fine with this include header

#if defined(__IPHONE__) || defined(__ANDROID__)
    #include "SDL_opengles2.h"
    #include "SDL_opengles2_gl2.h"
    #include "SDL_opengles2_gl2ext.h"
#elif defined(__APPLE__)
#include <OpenGL/gl3.h>
#include <SDL2/SDL_opengl.h>
#endif

I am getting this error when trying to build with ndk-build

jni/src/mandelbrot.c:100:5: warning: implicit declaration of function 'glGenVertexArrays' [-Wimplicit-function-declaration]
     glGenVertexArrays(1, &vao);
     ^
jni/src/mandelbrot.c:106:5: warning: implicit declaration of function 'glBindVertexArray' [-Wimplicit-function-declaration]
     glBindVertexArray(vao); //bind vertex array buffer

I was told that on android openles2 it's an extension and according to official opengl documentation

you use it like this: glGenVertexArraysOES(...) well that produces the same error as above except it's me implicit declaration of function glGenVertexArraysOES instead.

full android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_CFLAGS += -std=c99

LOCAL_MODULE := main

SDL_PATH := ../SDL
SDL_IMG_PATH := ../SDL2_image

LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SDL_IMG_PATH)/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SDL_IMG_PATH)/external/jpeg-9/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SDL_IMG_PATH)/external/libpng-1.6.2/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SDL_IMG_PATH)/external/libwebp-0.3.0/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/utils/time_utils/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/utils/resource_utils/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ren_opengl/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/core_math/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/core_math/commons_math/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/core_math/mat4_scalar/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/core_math/vec3_scalar/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/components/renderable2d/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/core_engine/

# Add your application source files here...
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
                utils/time_utils/time_utils.c \
                utils/resource_utils/resource_utils.c \
                ren_opengl/ren_opengl.c \
                core_math/core_math.c \
                core_math/mat4_scalar/mat4_scalar.c \
                core_math/vec3_scalar/vec3_scalar.c \
                components/renderable2d/renderable2d.c \
                core_engine/core_engine.c \
                mandelbrot.c


LOCAL_SHARED_LIBRARIES := SDL2 SDL2_image

LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog

include $(BUILD_SHARED_LIBRARY)

manually removing the reference to opengl1 has no affect on the outcome of the build.

edit according to @Michaels reply Doing this:

PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress ( "glGenVertexArraysOES" );

I get these error messages:

Brother:android-project blubee$ ndk-build
Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 10 in ./AndroidManifest.xml    
[armeabi] Install        : libSDL2.so => libs/armeabi/libSDL2.so
[armeabi] Install        : libSDL2_image.so => libs/armeabi/libSDL2_image.so
[armeabi] Compile thumb  : main <= mandelbrot.c
jni/src/mandelbrot.c:35:1: warning: data definition has no type or storage class [enabled by default]
 glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress ( "glGenVertexArraysOES" );
 ^
jni/src/mandelbrot.c:35:1: warning: type defaults to 'int' in declaration of 'glGenVertexArraysOES' [enabled by default]
jni/src/mandelbrot.c:35:1: error: conflicting types for 'glGenVertexArraysOES'
jni/src/mandelbrot.c:34:29: note: previous declaration of 'glGenVertexArraysOES' was here
 PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
                             ^
jni/src/mandelbrot.c:35:1: warning: implicit declaration of function 'eglGetProcAddress' [-Wimplicit-function-declaration]
 glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress ( "glGenVertexArraysOES" );

if I completely change the name to something like OES1 then that error goes away but then I get these errors.

jni/src/mandelbrot.c:54: error: undefined reference to 'eglGetProcAddress'
jni/src/mandelbrot.c:55: error: undefined reference to 'eglGetProcAddress'
jni/src/mandelbrot.c:56: error: undefined reference to 'eglGetProcAddress'
jni/src/mandelbrot.c:57: error: undefined reference to 'eglGetProcAddress'
     ^
    jni/src/mandelbrot.c:35:24: warning: initialization makes integer from pointer without a cast [enabled by default]
     glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress ( "glGenVertexArraysOES" );
                            ^
    jni/src/mandelbrot.c:35:1: error: initializer element is not constant
     glGenVertexArraysOES = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress ( "glGenVertexArraysOES" );
     ^
    jni/src/mandelbrot.c: In function 'initialized':
    jni/src/mandelbrot.c:102:5: warning: implicit declaration of function 'glGenVertexArrays' [-Wimplicit-function-declaration]
         glGenVertexArrays(1, &vao);
         ^
    jni/src/mandelbrot.c:108:5: warning: implicit declaration of function 'glBindVertexArray' [-Wimplicit-function-declaration]
         glBindVertexArray(vao); //bind vertex array buffer
         ^
    make: *** [obj/local/armeabi/objs/main/mandelbrot.o] Error 1

Upvotes: 2

Views: 2941

Answers (1)

user1906
user1906

Reputation: 2340

Check this answer using dlopen instead of eglGetProcAddress: https://stackoverflow.com/a/24878621/1762681

Also, check your headers. The SDL headers may be including definitions in addition to those defined in gl.h and glext.h. Do they include EGL/egl.h and EGL/eglext.h?

Upvotes: 1

Related Questions