diff options
author | Mathias Agopian <mathias@google.com> | 2009-08-06 16:25:37 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-08-06 16:26:15 -0700 |
commit | 653870d5e945ff94ff8136c97db0a016fc119683 (patch) | |
tree | 46f6eb9cff99f9ca6b3c3d1469cfadf045782f62 /opengl/tests/textures | |
parent | 6cf50a770dabd13cf5b72bb0a6fb9dd002c88db6 (diff) | |
download | frameworks_native-653870d5e945ff94ff8136c97db0a016fc119683.zip frameworks_native-653870d5e945ff94ff8136c97db0a016fc119683.tar.gz frameworks_native-653870d5e945ff94ff8136c97db0a016fc119683.tar.bz2 |
update most gl tests to use EGLUtils
Diffstat (limited to 'opengl/tests/textures')
-rw-r--r-- | opengl/tests/textures/Android.mk | 4 | ||||
-rw-r--r-- | opengl/tests/textures/textures.cpp (renamed from opengl/tests/textures/textures.c) | 54 |
2 files changed, 20 insertions, 38 deletions
diff --git a/opengl/tests/textures/Android.mk b/opengl/tests/textures/Android.mk index 8d5f56d..b2fa185 100644 --- a/opengl/tests/textures/Android.mk +++ b/opengl/tests/textures/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - textures.c + textures.cpp LOCAL_SHARED_LIBRARIES := \ libcutils \ @@ -14,4 +14,6 @@ LOCAL_MODULE:= test-opengl-textures LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES + include $(BUILD_EXECUTABLE) diff --git a/opengl/tests/textures/textures.c b/opengl/tests/textures/textures.cpp index d877e74..ee92e79 100644 --- a/opengl/tests/textures/textures.c +++ b/opengl/tests/textures/textures.cpp @@ -22,59 +22,39 @@ #include <GLES/gl.h> #include <GLES/glext.h> +#include <ui/FramebufferNativeWindow.h> +#include <ui/EGLUtils.h> + +using namespace android; + int main(int argc, char** argv) { - EGLint s_configAttribs[] = { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, + EGLint configAttribs[] = { + EGL_DEPTH_SIZE, 0, EGL_NONE }; - EGLint numConfigs = -1, n=0; EGLint majorVersion; EGLint minorVersion; - EGLConfig config; EGLContext context; + EGLConfig config; EGLSurface surface; EGLint w, h; - EGLDisplay dpy; dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(dpy, &majorVersion, &minorVersion); + + EGLNativeWindowType window = android_createDisplaySurface(); - // Get all the "potential match" configs... - eglGetConfigs(dpy, NULL, 0, &numConfigs); - EGLConfig* const configs = malloc(sizeof(EGLConfig)*numConfigs); - eglChooseConfig(dpy, s_configAttribs, configs, numConfigs, &n); - config = configs[0]; - if (n > 1) { - // if there is more than one candidate, go through the list - // and pick one that matches our framebuffer format - int fbSzA = 0; // should not hardcode - int fbSzR = 5; // should not hardcode - int fbSzG = 6; // should not hardcode - int fbSzB = 5; // should not hardcode - int i; - for (i=0 ; i<n ; i++) { - EGLint r,g,b,a; - eglGetConfigAttrib(dpy, configs[i], EGL_RED_SIZE, &r); - eglGetConfigAttrib(dpy, configs[i], EGL_GREEN_SIZE, &g); - eglGetConfigAttrib(dpy, configs[i], EGL_BLUE_SIZE, &b); - eglGetConfigAttrib(dpy, configs[i], EGL_ALPHA_SIZE, &a); - if (fbSzA == a && fbSzR == r && fbSzG == g && fbSzB == b) { - config = configs[i]; - break; - } - } + status_t err = EGLUtils::selectConfigForNativeWindow( + dpy, configAttribs, window, &config); + if (err) { + fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n"); + return 0; } - free(configs); - - - - surface = eglCreateWindowSurface(dpy, config, - android_createDisplaySurface(), NULL); + + surface = eglCreateWindowSurface(dpy, config, window, NULL); context = eglCreateContext(dpy, config, NULL, NULL); eglMakeCurrent(dpy, surface, surface, context); eglQuerySurface(dpy, surface, EGL_WIDTH, &w); |