简体   繁体   English

如何使用Android NDK调用“ glEnable”?

[英]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. 我正在尝试对android环境进行世界上最简单的测试,只是在处理端口之前先让我所有的鸭子都排成一行。

The very FIRST thing I need to do is just link GLES 1.0 ... here's the steps I took: 我要做的第一件事就是链接GLES 1.0 ...这是我采取的步骤:

ONE: Using Android Studio 2.3.2, I created a new C++ enabled project with a basic activity 一个:使用Android Studio 2.3.2,我创建了一个具有基本活动的新的启用C ++的项目

TWO: in AndroidManifest.xml I added this: 二:在AndroidManifest.xml中,我添加了以下内容:

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

THREE: In CMakeLists.txt I added these lines: 三:在CMakeLists.txt中,我添加了以下几行:

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) 这适用于log-lib,也适用于zlib ...不适用于GLES1(请参阅下一步)

FOUR: I just added one simple line to native-lib.cpp 第四:我只是向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. 我尝试了GLES1_LIBRARY的各种迭代(例如GLES_LIBRARY等),但是没有任何效果。

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 另外,您已将${GLES1_LIBRARIES}定位${GLES1_LIBRARIES}目标,但在上方已将其拼写为GLES1_LIBRARY


If you can, I would suggest porting to gles2. 如果可以,我建议移植到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? 顺便说一句,这与使用PopCap框架创建Chuzzle的Rapitsoft相同吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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