gpt4 book ai didi

android - opengles2 glGenVertexArrays ... glGenVertexArraysOES

转载 作者:太空宇宙 更新时间:2023-11-04 04:34:45 24 4
gpt4 key购买 nike

我在解决这个问题时遇到了一些麻烦。我在 mac os x 10.9 上使用 cmake 构建了我的 SDL opengl 应用程序,它可以很好地处理这个包含 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

尝试使用 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 上它是一个扩展,according to official opengl documentation

你像这样使用它: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

最佳答案

使用 dlopen 而不是 eglGetProcAddress 检查这个答案:https://stackoverflow.com/a/24878621/1762681

此外,请检查您的 header 。 SDL header 可能包含除 gl.h 和 glext.h 中定义的定义之外的定义。它们是否包括 EGL/egl.h 和 EGL/eglext.h?

关于android - opengles2 glGenVertexArrays ... glGenVertexArraysOES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32044912/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com