Opengl es 未定义对“glReadBuffer';在Android中

Opengl es 未定义对“glReadBuffer';在Android中,opengl-es,opengl-es-2.0,Opengl Es,Opengl Es 2.0,我尝试创建一个JNI GLES3渲染器。这是我的CmakeLists.txt: set(CMAKE_VERBOSE_MAKEFILE on) project("librenderer") add_definitions("-std=c++11") # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # Y

我尝试创建一个JNI GLES3渲染器。这是我的CmakeLists.txt:

set(CMAKE_VERBOSE_MAKEFILE on)
project("librenderer")

add_definitions("-std=c++11")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
             librenderer

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
             src/main/jni/renderer/gl_utils.cpp
             src/main/jni/renderer/gpu_renderer.cpp
             src/main/jni/renderer/rendererjni_wrapper.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

find_library( # Sets the name of the path variable.
            GLESv2-lib

            # Specifies the name of the NDK library that
            # you want CMake to locate.
            GLESv2 )


find_library( # Sets the name of the path variable.
            EGL-lib

            # Specifies the name of the NDK library that
            # you want CMake to locate.
            EGL )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                       librenderer

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib}
                       ${GLESv2-lib}
                       ${EGL-lib})
当我使用像glReadBuffer这样的函数时,我得到错误:

  /home/xavier/dev/myapp/src/main/jni/renderer/gl_utils.cpp:171: undefined reference to `glReadBuffer'
  /home/xavier/dev/myapp/src/main/jni/renderer/gl_utils.cpp:174: undefined reference to `glMapBufferRange'
  /home/xavier/dev/myapp/src/main/jni/renderer/gl_utils.cpp:180: undefined reference to `glUnmapBuffer'
在编译过程中,GLES库被很好地添加到compile命令中:

AILED: : && /home/xavier/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++  --target=aarch64-none-linux-android --gcc-toolchain=/home/xavier/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 --sysroot=/home/xavier/Android/Sdk/ndk-bundle/sysroot -fPIC -isystem /home/xavier/Android/Sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=24 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security   -O2 -DNDEBUG  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a --sysroot /home/xavier/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm64 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,liblibrenderer.so -o ../../../../build/intermediates/cmake/release/obj/arm64-v8a/liblibrenderer.so CMakeFiles/librenderer.dir/src/main/jni/renderer/gl_utils.cpp.o CMakeFiles/librenderer.dir/src/main/jni/renderer/gpu_renderer.cpp.o CMakeFiles/librenderer.dir/src/main/jni/renderer/rendererjni_wrapper.cpp.o  /home/xavier/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm64/usr/lib/liblog.so /home/xavier/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm64/usr/lib/libGLESv2.so /home/xavier/Android/Sdk/ndk-bundle/platforms/android-24/arch-arm64/usr/lib/libEGL.so -latomic -lm "/home/xavier/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" && :
我不知道我是否必须在cpp程序中添加一些东西来使用这些函数


有人能帮我吗?

我可以从您的代码中清楚地看到您正在链接openGL ES 2.0库。据我所知,
glReadBuffer、glMapBufferRange和glUnmapBuffer
是openGL ES 3的一部分,显然在GLESv2库中不会出现。因此,您需要将库更改为适当的库