Install OpenGL ES and compile code for android

前端 未结 4 1264
天涯浪人
天涯浪人 2021-02-15 14:27

I\'ve just started learning OpenGL ES on android (using this book) and came across an issue of adopting source code from chapter 5 to existing methods of using jni in android (a

相关标签:
4条回答
  • 2021-02-15 14:38

    I just added

    #include <jni.h>
    

    to cube.c & cuberenderer.c

    Changed

    (*g_VM)->AttachCurrentThread (g_VM, (void **) &env, NULL);
    

    to

    (*g_VM)->AttachCurrentThread (g_VM, (const struct JNINativeInterface ***) &env, NULL);
    

    My Android.mk:

    LOCAL_PATH:= $(call my-dir)
    
    include $(CLEAR_VARS)
    
    LOCAL_MODULE    := libgltest_jni
    LOCAL_CFLAGS    := -Werror
    LOCAL_SRC_FILES := cube.c cuberenderer.c
    LOCAL_LDLIBS    := -llog
    -lGLESv1_CM
    
    include $(BUILD_SHARED_LIBRARY)
    

    My Application.mk:

    # The ARMv7 is significanly faster due to the use of the hardware FPU
    APP_ABI := armeabi armeabi-v7a
    APP_PLATFORM := android-9
    

    And built it on android-ndk-r6

    0 讨论(0)
  • 2021-02-15 14:53

    You used the filename GLES/glext.h twice.

    0 讨论(0)
  • 2021-02-15 15:00

    Those libraries are provided by Android itself. However, setting up your project to find them and compile your JNI (native) code correctly can be daunting.

    I recommend using glbuffer as a starting project, as it will provide you with a GLSurfaceView to draw on and set you up with the proper Android libraries.

    The details of linking to the Android libraries are contained in jni/Android.mk inside that project if you'd like to give it a shot yourself from scratch.

    Edit - apparently glbuffer is missing jni/Application.mk. Create it and put this inside:

    APP_ABI := armeabi armeabi-v7a
    APP_PLATFORM := android-8
    

    Then the ndk will know to look inside the android-8 platform for your includes. You can change this to other versions as needed.

    0 讨论(0)
  • 2021-02-15 15:01

    I searched the NDK for instances of the "EGL/egl.h" header file. This particular example will compile and run on Android API level 15, but some other API levels don't have the header.

    0 讨论(0)
提交回复
热议问题