简体   繁体   中英

How can I call “glEnable” using Android NDK?

I'm trying to make the world's simplest test of an android environment, just to get all my ducks in a row before tackling the port.

The very FIRST thing I need to do is just link GLES 1.0 ... here's the steps I took:

ONE: Using Android Studio 2.3.2, I created a new C++ enabled project with a basic activity

TWO: in AndroidManifest.xml I added this:

<uses-feature android:glEsVersion="0x00010000" />

THREE: In CMakeLists.txt I added these lines:

find_package( ZLIB REQUIRED )
find_library( GLES1_LIBRARY names GLESv1_CM )
include_directories( ${ZLIB_INCLUDE_DIRS} ${GLES_INCLUDE_DIRS} )
...
target_link_libraries( # Specifies the target library.
                   native-lib
                   ${ZLIB_LIBRARIES}
                   ${GLES1_LIBRARIES}
                   ${log-lib} )

That works for log-lib, and it works for zlib too... it doesn't work for GLES1 (see next step)

FOUR: I just added one simple line to native-lib.cpp

 glEnable(GL_BLEND);

Hit compile and...

CMakeFiles/native-lib.dir/src/main/cpp/native-lib.cpp.o: In function `Java_com_game_raptisoft_myapplication_MainActivity_stringFromJNI':
C:\Users\Raptisoft2011\Desktop\Android\MyApplication\app\src\main\cpp/native-lib.cpp:12: undefined reference to `glEnable'

How do I resolve this problem? Are there more link statements I need to include? I've tried various iterations of GLES1_LIBRARY (like GLES_LIBRARY, etc) but nothing works.

Try

target_link_libraries( # Specifies the target library.
               native-lib
               ${ZLIB_LIBRARIES}
               EGL
               GLESv1_CM
               ${log-lib} )

Also, you have targeted ${GLES1_LIBRARIES} , but above you've spelled it GLES1_LIBRARY


If you can, I would suggest porting to gles2. The most you would have to worry about is writing shaders, and it gives you better control over how your data is drawn.


BTW, is this the same Rapitsoft that created Chuzzle using the PopCap framework?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM