Обратите внимание что код расчитан на компиляцию системой сборки Android (вам понадобятся исходники платформы чтобы собрать). Я не пробовал собирать с помощью NDK.
Например она выводит следуюущую информацию, если запущена на PandaBoard Rev.B ES:
EGL version 1.4 EGL_VERSION = 1.4 Android META-EGL EGL_VENDOR = Android EGL_EXTENSIONS = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_base EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer EGL_ANDROID_image_native_buffer EGL_CLIENT_APIS = OpenGL ESНа эмуляторе Android 4.0:
EGL version 1.4 EGL_VERSION = 1.4 Android META-EGL EGL_VENDOR = Android EGL_EXTENSIONS = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_gl_renderbuffer_image EGL_KHR_fence_sync EGL_ANDROID_image_native_buffer EGL_ANDROID_swap_rectangle EGL_NV_system_time EGL_CLIENT_APIS = OpenGL ES
Android.mk:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils \ libEGL \ libGLESv2 LOCAL_C_INCLUDES += \ frameworks/base/opengl/include/GLES2 LOCAL_SRC_FILES:= hellogl.c LOCAL_MODULE := hellogl LOCAL_MODULE_TAGS := eng include $(BUILD_EXECUTABLE)
hellogl.c:
// vim: ts=4:sw=4 #include <stdio.h> #include <EGL/egl.h> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> static void checkEglError(const char* op, EGLBoolean returnVal) { EGLint error; if (returnVal != EGL_TRUE) { fprintf(stderr, "%s() returned %d\n", op, returnVal); } for (error = eglGetError(); error != EGL_SUCCESS; error = eglGetError()) { fprintf(stderr, "after %s() eglError %s (0x%x)\n", op, "<TBD>"/*EGLUtils::strerror(error)*/, error); } } int main() { const char * s; EGLBoolean returnValue; EGLConfig myConfig = {0}; EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLint s_configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; EGLint majorVersion; EGLint minorVersion; EGLContext context; EGLSurface surface; EGLint w, h; EGLDisplay egl_dpy; checkEglError("<init>", EGL_TRUE); egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); checkEglError("eglGetDisplay", EGL_TRUE); if (egl_dpy == EGL_NO_DISPLAY) { printf("eglGetDisplay returned EGL_NO_DISPLAY.\n"); return 0; } returnValue = eglInitialize(egl_dpy, &majorVersion, &minorVersion); checkEglError("eglInitialize", returnValue); fprintf(stderr, "EGL version %d.%d\n", majorVersion, minorVersion); if (returnValue != EGL_TRUE) { printf("eglInitialize failed\n"); return 0; } printf("HelloGL 0.001\n"); s = eglQueryString(egl_dpy, EGL_VERSION); printf("EGL_VERSION = %s\n", s); s = eglQueryString(egl_dpy, EGL_VENDOR); printf("EGL_VENDOR = %s\n", s); s = eglQueryString(egl_dpy, EGL_EXTENSIONS); printf("EGL_EXTENSIONS = %s\n", s); s = eglQueryString(egl_dpy, EGL_CLIENT_APIS); printf("EGL_CLIENT_APIS = %s\n", s); return 0; }
Комментариев нет:
Отправить комментарий