1

これを整理するのに少し苦労しています。Mac os x 10.9でcmakeを使用してSDL openglアプリをビルドしましたが、このインクルードヘッダーで正常に動作します

#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

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

Android openles2では拡張機能であり、公式のopenglドキュメントによると、私は言われました

このように使用します。これglGenVertexArraysOES(...)は、関数 glGenVertexArraysOES の暗黙の宣言であることを除いて、上記と同じエラーを生成します。

完全な 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)

opengl1 への参照を手動で削除しても、ビルドの結果には影響しません。

@Michaelsの返信に従って編集するこれを 行う:

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

次のエラー メッセージが表示されます。

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" );

名前を OES1 のような名前に完全に変更すると、そのエラーはなくなりますが、これらのエラーが発生します。

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
4

1 に答える 1

0

eglGetProcAddress の代わりに dlopen を使用してこの回答を確認してください: https://stackoverflow.com/a/24878621/1762681

また、ヘッダーを確認してください。SDL ヘッダーには、gl.h および glext.h で定義されているものに加えて、定義が含まれている場合があります。EGL/egl.h と EGL/eglext.h は含まれていますか?

于 2015-08-18T05:04:33.160 に答える