Install OpenGL ES and compile code for android

本小妞迷上赌 提交于 2019-12-03 13:12:25

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.

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.

Tim

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

You used the filename GLES/glext.h twice.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!