Android:NDK:OpenGLES
lastmod 2018-08-17created 2016-05-173 edits
Notes on how to implement Android OpenGLES in the NDK.
How to use
To use it from JNI, you need to add the related libraries. The list of related libraries is below.
Using OpenGLES 2.0
On Android, if you use OpenGLES without any extra configuration, it runs based on version 1.0. 1
| Warning |
| OpenGLES 1.x and OpenGLES 2.0 are not compatible. |
You also need to add -lGLESv2 to the LOCAL_LDLIBS option in the Android.mk build configuration file. In C/C++, you can use opengl es 2.0 by including the two headers #include <GLES2/gl2.h> and #include <GLES2/gl2ext.h>. How to display OpenGLES information is shown below:
static void PrintGLString(const char *name, GLenum s)
{
const char *v = (const char *) glGetString(s);
LOGI(TAG, "GL %s = %s\n", name, v);
}
static void printOpenGLInfo()
{
PrintGLString("Version", GL_VERSION); // OpenGLES Version 표시
PrintGLString("Vendor", GL_VENDOR); // Chip set Vendor
PrintGLString("Renderer", GL_RENDERER); // 그래픽 칩셋 모델 정보.
PrintGLString("Extensions", GL_EXTENSIONS); // 좀더 자세한 정보를 보실수 있습니다.
}
Android OpenGLES NDK tutorial list
See the files below.
- NDK OpenGL 01 Preparing the project: Berabue_android_ndk_opengl_01.pdf
- NDK OpenGL 02 Setting the resolution: Berabue_android_ndk_opengl_02.pdf
- NDK OpenGL 03 Applying textures: Berabue_android_ndk_opengl_03.pdf
- NDK OpenGL 04 Creating a thread: Berabue_android_ndk_opengl_04.pdf
- NDK OpenGL 05 Rendering non-power-of-two textures: Berabue_android_ndk_opengl_05.pdf
- NDK OpenGL 06 Textures my way: Berabue_android_ndk_opengl_06.pdf
See also
Favorite site
References
-
For an example that uses OpenGLES version 2.0, see
Graphic -> OpenGL ES -> OpenGL ES 2.0in APIDemo. ↩