From 265d9c076a588cf4cd811fbafd999c7ffe36641b Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 6 Aug 2009 16:05:39 -0700 Subject: added two EGL helpers for selecting a config matching a certain pixelformat or native window type --- opengl/tests/swapinterval/swapinterval.cpp | 42 ++++++++---------------------- 1 file changed, 11 insertions(+), 31 deletions(-) (limited to 'opengl/tests') diff --git a/opengl/tests/swapinterval/swapinterval.cpp b/opengl/tests/swapinterval/swapinterval.cpp index f51d882..cf908a0 100644 --- a/opengl/tests/swapinterval/swapinterval.cpp +++ b/opengl/tests/swapinterval/swapinterval.cpp @@ -26,6 +26,7 @@ #include #include +#include using namespace android; @@ -36,48 +37,27 @@ int main(int argc, char** argv) 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 = (EGLConfig*)malloc(sizeof(EGLConfig)*numConfigs); - eglChooseConfig(dpy, 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 Date: Thu, 6 Aug 2009 16:25:37 -0700 Subject: update most gl tests to use EGLUtils --- opengl/tests/angeles/Android.mk | 2 +- opengl/tests/angeles/app-linux.c | 252 ------------------------------------- opengl/tests/angeles/app-linux.cpp | 213 +++++++++++++++++++++++++++++++ opengl/tests/fillrate/fillrate.cpp | 42 ++----- opengl/tests/filter/Android.mk | 4 +- opengl/tests/filter/filter.c | 130 ------------------- opengl/tests/filter/filter.cpp | 137 ++++++++++++++++++++ opengl/tests/finish/Android.mk | 4 +- opengl/tests/finish/finish.c | 224 --------------------------------- opengl/tests/finish/finish.cpp | 226 +++++++++++++++++++++++++++++++++ opengl/tests/textures/Android.mk | 4 +- opengl/tests/textures/textures.c | 138 -------------------- opengl/tests/textures/textures.cpp | 118 +++++++++++++++++ 13 files changed, 715 insertions(+), 779 deletions(-) delete mode 100644 opengl/tests/angeles/app-linux.c create mode 100644 opengl/tests/angeles/app-linux.cpp delete mode 100644 opengl/tests/filter/filter.c create mode 100644 opengl/tests/filter/filter.cpp delete mode 100644 opengl/tests/finish/finish.c create mode 100644 opengl/tests/finish/finish.cpp delete mode 100644 opengl/tests/textures/textures.c create mode 100644 opengl/tests/textures/textures.cpp (limited to 'opengl/tests') diff --git a/opengl/tests/angeles/Android.mk b/opengl/tests/angeles/Android.mk index e193483..d0c3221 100644 --- a/opengl/tests/angeles/Android.mk +++ b/opengl/tests/angeles/Android.mk @@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_SRC_FILES:= app-linux.c demo.c.arm +LOCAL_SRC_FILES:= app-linux.cpp demo.c.arm LOCAL_SHARED_LIBRARIES := libEGL libGLESv1_CM libui LOCAL_MODULE:= angeles LOCAL_MODULE_TAGS := optional diff --git a/opengl/tests/angeles/app-linux.c b/opengl/tests/angeles/app-linux.c deleted file mode 100644 index 6be4876..0000000 --- a/opengl/tests/angeles/app-linux.c +++ /dev/null @@ -1,252 +0,0 @@ -/* San Angeles Observation OpenGL ES version example - * Copyright 2004-2005 Jetro Lauha - * All rights reserved. - * Web: http://iki.fi/jetro/ - * - * This source is free software; you can redistribute it and/or - * modify it under the terms of EITHER: - * (1) The GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at - * your option) any later version. The text of the GNU Lesser - * General Public License is included with this source in the - * file LICENSE-LGPL.txt. - * (2) The BSD-style license that is included with this source in - * the file LICENSE-BSD.txt. - * - * This source is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files - * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details. - * - * $Id: app-linux.c,v 1.4 2005/02/08 18:42:48 tonic Exp $ - * $Revision: 1.4 $ - * - * Parts of this source file is based on test/example code from - * GLESonGL implementation by David Blythe. Here is copy of the - * license notice from that source: - * - * Copyright (C) 2003 David Blythe All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * DAVID BLYTHE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include -#include - -#include -#include - -#include "app.h" - - -int gAppAlive = 1; - -static const char sAppName[] = - "San Angeles Observation OpenGL ES version example (Linux)"; - -static int sWindowWidth = WINDOW_DEFAULT_WIDTH; -static int sWindowHeight = WINDOW_DEFAULT_HEIGHT; -static EGLDisplay sEglDisplay = EGL_NO_DISPLAY; -static EGLContext sEglContext = EGL_NO_CONTEXT; -static EGLSurface sEglSurface = EGL_NO_SURFACE; - -const char *egl_strerror(unsigned err) -{ - switch(err){ - case EGL_SUCCESS: return "SUCCESS"; - case EGL_NOT_INITIALIZED: return "NOT INITIALIZED"; - case EGL_BAD_ACCESS: return "BAD ACCESS"; - case EGL_BAD_ALLOC: return "BAD ALLOC"; - case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE"; - case EGL_BAD_CONFIG: return "BAD CONFIG"; - case EGL_BAD_CONTEXT: return "BAD CONTEXT"; - case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE"; - case EGL_BAD_DISPLAY: return "BAD DISPLAY"; - case EGL_BAD_MATCH: return "BAD MATCH"; - case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP"; - case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW"; - case EGL_BAD_PARAMETER: return "BAD PARAMETER"; - case EGL_BAD_SURFACE: return "BAD_SURFACE"; -// case EGL_CONTEXT_LOST: return "CONTEXT LOST"; - default: return "UNKNOWN"; - } -} - -void egl_error(const char *name) -{ - unsigned err = eglGetError(); - if(err != EGL_SUCCESS) { - fprintf(stderr,"%s(): egl error 0x%x (%s)\n", - name, err, egl_strerror(err)); - } -} - -static void checkGLErrors() -{ - GLenum error = glGetError(); - if (error != GL_NO_ERROR) - fprintf(stderr, "GL Error: 0x%04x\n", (int)error); -} - - -static void checkEGLErrors() -{ - EGLint error = eglGetError(); - // GLESonGL seems to be returning 0 when there is no errors? - if (error && error != EGL_SUCCESS) - fprintf(stderr, "EGL Error: 0x%04x\n", (int)error); -} - -static int initGraphics() -{ - EGLint s_configAttribs[] = { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - #if 1 - EGL_DEPTH_SIZE, 16, - EGL_STENCIL_SIZE, 0, - #else - EGL_ALPHA_SIZE, EGL_DONT_CARE, - EGL_DEPTH_SIZE, EGL_DONT_CARE, - EGL_STENCIL_SIZE, EGL_DONT_CARE, - EGL_SURFACE_TYPE, EGL_DONT_CARE, - #endif - EGL_NONE - }; - - EGLint numConfigs = -1; - EGLint n = 0; - EGLint majorVersion; - EGLint minorVersion; - EGLConfig config; - EGLContext context; - EGLSurface surface; - - EGLDisplay dpy; - - dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - egl_error("eglGetDisplay"); - fprintf(stderr,"dpy = 0x%08x\n", (unsigned) dpy); - - eglInitialize(dpy, &majorVersion, &minorVersion); - egl_error("eglInitialize"); - - eglGetConfigs(dpy, NULL, 0, &numConfigs); - - // Get all the "potential match" configs... - 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 +#include +#include + +#include +#include + +#include +#include + +using namespace android; + +#include "app.h" + + +int gAppAlive = 1; + +static const char sAppName[] = + "San Angeles Observation OpenGL ES version example (Linux)"; + +static int sWindowWidth = WINDOW_DEFAULT_WIDTH; +static int sWindowHeight = WINDOW_DEFAULT_HEIGHT; +static EGLDisplay sEglDisplay = EGL_NO_DISPLAY; +static EGLContext sEglContext = EGL_NO_CONTEXT; +static EGLSurface sEglSurface = EGL_NO_SURFACE; + +const char *egl_strerror(unsigned err) +{ + switch(err){ + case EGL_SUCCESS: return "SUCCESS"; + case EGL_NOT_INITIALIZED: return "NOT INITIALIZED"; + case EGL_BAD_ACCESS: return "BAD ACCESS"; + case EGL_BAD_ALLOC: return "BAD ALLOC"; + case EGL_BAD_ATTRIBUTE: return "BAD_ATTRIBUTE"; + case EGL_BAD_CONFIG: return "BAD CONFIG"; + case EGL_BAD_CONTEXT: return "BAD CONTEXT"; + case EGL_BAD_CURRENT_SURFACE: return "BAD CURRENT SURFACE"; + case EGL_BAD_DISPLAY: return "BAD DISPLAY"; + case EGL_BAD_MATCH: return "BAD MATCH"; + case EGL_BAD_NATIVE_PIXMAP: return "BAD NATIVE PIXMAP"; + case EGL_BAD_NATIVE_WINDOW: return "BAD NATIVE WINDOW"; + case EGL_BAD_PARAMETER: return "BAD PARAMETER"; + case EGL_BAD_SURFACE: return "BAD_SURFACE"; +// case EGL_CONTEXT_LOST: return "CONTEXT LOST"; + default: return "UNKNOWN"; + } +} + +void egl_error(const char *name) +{ + unsigned err = eglGetError(); + if(err != EGL_SUCCESS) { + fprintf(stderr,"%s(): egl error 0x%x (%s)\n", + name, err, egl_strerror(err)); + } +} + +static void checkGLErrors() +{ + GLenum error = glGetError(); + if (error != GL_NO_ERROR) + fprintf(stderr, "GL Error: 0x%04x\n", (int)error); +} + + +static void checkEGLErrors() +{ + EGLint error = eglGetError(); + // GLESonGL seems to be returning 0 when there is no errors? + if (error && error != EGL_SUCCESS) + fprintf(stderr, "EGL Error: 0x%04x\n", (int)error); +} + +static int initGraphics() +{ + EGLint configAttribs[] = { + EGL_DEPTH_SIZE, 16, + EGL_NONE + }; + + EGLint majorVersion; + EGLint minorVersion; + EGLContext context; + EGLConfig config; + EGLSurface surface; + EGLint w, h; + EGLDisplay dpy; + + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(dpy, &majorVersion, &minorVersion); + + EGLNativeWindowType window = android_createDisplaySurface(); + + 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; + } + + surface = eglCreateWindowSurface(dpy, config, window, NULL); + egl_error("eglCreateWindowSurface"); + + fprintf(stderr,"surface = %p\n", surface); + + context = eglCreateContext(dpy, config, NULL, NULL); + egl_error("eglCreateContext"); + fprintf(stderr,"context = %p\n", context); + + eglMakeCurrent(dpy, surface, surface, context); + egl_error("eglMakeCurrent"); + + eglQuerySurface(dpy, surface, EGL_WIDTH, &sWindowWidth); + eglQuerySurface(dpy, surface, EGL_HEIGHT, &sWindowHeight); + + sEglDisplay = dpy; + sEglSurface = surface; + sEglContext = context; + + return EGL_TRUE; +} + + +static void deinitGraphics() +{ + eglMakeCurrent(sEglDisplay, NULL, NULL, NULL); + eglDestroyContext(sEglDisplay, sEglContext); + eglDestroySurface(sEglDisplay, sEglSurface); + eglTerminate(sEglDisplay); +} + + +int main(int argc, char *argv[]) +{ + // not referenced: + argc = argc; + argv = argv; + + if (!initGraphics()) + { + fprintf(stderr, "Graphics initialization failed.\n"); + return EXIT_FAILURE; + } + + appInit(); + + while (gAppAlive) + { + struct timeval timeNow; + + if (gAppAlive) + { + gettimeofday(&timeNow, NULL); + appRender(timeNow.tv_sec * 1000 + timeNow.tv_usec / 1000, + sWindowWidth, sWindowHeight); + checkGLErrors(); + eglSwapBuffers(sEglDisplay, sEglSurface); + checkEGLErrors(); + } + } + + appDeinit(); + deinitGraphics(); + + return EXIT_SUCCESS; +} diff --git a/opengl/tests/fillrate/fillrate.cpp b/opengl/tests/fillrate/fillrate.cpp index 108a87c..4ffbc8b 100644 --- a/opengl/tests/fillrate/fillrate.cpp +++ b/opengl/tests/fillrate/fillrate.cpp @@ -26,6 +26,7 @@ #include #include +#include using namespace android; @@ -36,48 +37,27 @@ int main(int argc, char** argv) 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 = (EGLConfig*)malloc(sizeof(EGLConfig)*numConfigs); - eglChooseConfig(dpy, 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 -#include - -#include -#include -#include - -int main(int argc, char** argv) -{ - if (argc!=2 && argc!=3) { - printf("usage: %s <0-6> [pbuffer]\n", argv[0]); - return 0; - } - - const int test = atoi(argv[1]); - int usePbuffer = argc==3 && !strcmp(argv[2], "pbuffer"); - EGLint s_configAttribs[] = { - EGL_SURFACE_TYPE, EGL_PBUFFER_BIT|EGL_WINDOW_BIT, - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_NONE - }; - - EGLint numConfigs = -1; - EGLint majorVersion; - EGLint minorVersion; - EGLConfig config; - EGLContext context; - EGLSurface surface; - EGLint w, h; - - EGLDisplay dpy; - - dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - eglInitialize(dpy, &majorVersion, &minorVersion); - eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs); - if (!usePbuffer) { - surface = eglCreateWindowSurface(dpy, config, - android_createDisplaySurface(), NULL); - } else { - printf("using pbuffer\n"); - EGLint attribs[] = { EGL_WIDTH, 320, EGL_HEIGHT, 480, EGL_NONE }; - surface = eglCreatePbufferSurface(dpy, config, attribs); - if (surface == EGL_NO_SURFACE) { - printf("eglCreatePbufferSurface error %x\n", eglGetError()); - } - } - context = eglCreateContext(dpy, config, NULL, NULL); - eglMakeCurrent(dpy, surface, surface, context); - eglQuerySurface(dpy, surface, EGL_WIDTH, &w); - eglQuerySurface(dpy, surface, EGL_HEIGHT, &h); - GLint dim = w +#include + +#include +#include +#include + +#include +#include + +using namespace android; + +int main(int argc, char** argv) +{ + if (argc!=2 && argc!=3) { + printf("usage: %s <0-6> [pbuffer]\n", argv[0]); + return 0; + } + + const int test = atoi(argv[1]); + int usePbuffer = argc==3 && !strcmp(argv[2], "pbuffer"); + EGLint s_configAttribs[] = { + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT|EGL_WINDOW_BIT, + EGL_RED_SIZE, 5, + EGL_GREEN_SIZE, 6, + EGL_BLUE_SIZE, 5, + EGL_NONE + }; + + EGLint numConfigs = -1; + EGLint majorVersion; + EGLint minorVersion; + EGLConfig config; + EGLContext context; + EGLSurface surface; + EGLint w, h; + + EGLDisplay dpy; + + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(dpy, &majorVersion, &minorVersion); + if (!usePbuffer) { + EGLNativeWindowType window = android_createDisplaySurface(); + surface = eglCreateWindowSurface(dpy, config, window, NULL); + EGLUtils::selectConfigForNativeWindow( + dpy, s_configAttribs, window, &config); + } else { + printf("using pbuffer\n"); + eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs); + EGLint attribs[] = { EGL_WIDTH, 320, EGL_HEIGHT, 480, EGL_NONE }; + surface = eglCreatePbufferSurface(dpy, config, attribs); + if (surface == EGL_NO_SURFACE) { + printf("eglCreatePbufferSurface error %x\n", eglGetError()); + } + } + context = eglCreateContext(dpy, config, NULL, NULL); + eglMakeCurrent(dpy, surface, surface, context); + eglQuerySurface(dpy, surface, EGL_WIDTH, &w); + eglQuerySurface(dpy, surface, EGL_HEIGHT, &h); + GLint dim = w -#include -#include -#include -#include - -#include -#include -#include - - -long long systemTime() -{ - struct timespec t; - t.tv_sec = t.tv_nsec = 0; - clock_gettime(CLOCK_MONOTONIC, &t); - return (long long)(t.tv_sec)*1000000000LL + t.tv_nsec; -} - -int main(int argc, char** argv) -{ - EGLint s_configAttribs[] = { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_NONE - }; - - EGLint numConfigs = -1; - EGLint majorVersion; - EGLint minorVersion; - EGLConfig config; - EGLContext context; - EGLSurface surface; - EGLint w, h; - - EGLDisplay dpy; - - dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - eglInitialize(dpy, &majorVersion, &minorVersion); - eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs); - surface = eglCreateWindowSurface(dpy, config, - android_createDisplaySurface(), NULL); - context = eglCreateContext(dpy, config, NULL, NULL); - eglMakeCurrent(dpy, surface, surface, context); - eglQuerySurface(dpy, surface, EGL_WIDTH, &w); - eglQuerySurface(dpy, surface, EGL_HEIGHT, &h); - GLint dim = w +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +using namespace android; + +int main(int argc, char** argv) +{ + EGLint configAttribs[] = { + EGL_DEPTH_SIZE, 0, + EGL_NONE + }; + + EGLint majorVersion; + EGLint minorVersion; + EGLContext context; + EGLConfig config; + EGLSurface surface; + EGLint w, h; + EGLDisplay dpy; + + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(dpy, &majorVersion, &minorVersion); + + EGLNativeWindowType window = android_createDisplaySurface(); + + 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; + } + + surface = eglCreateWindowSurface(dpy, config, window, NULL); + context = eglCreateContext(dpy, config, NULL, NULL); + eglMakeCurrent(dpy, surface, surface, context); + eglQuerySurface(dpy, surface, EGL_WIDTH, &w); + eglQuerySurface(dpy, surface, EGL_HEIGHT, &h); + GLint dim = w -#include - -#include -#include -#include - -int main(int argc, char** argv) -{ - EGLint s_configAttribs[] = { - EGL_RED_SIZE, 5, - EGL_GREEN_SIZE, 6, - EGL_BLUE_SIZE, 5, - EGL_NONE - }; - - EGLint numConfigs = -1, n=0; - EGLint majorVersion; - EGLint minorVersion; - EGLConfig config; - EGLContext context; - EGLSurface surface; - EGLint w, h; - - EGLDisplay dpy; - - dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); - eglInitialize(dpy, &majorVersion, &minorVersion); - - // 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 +#include + +#include +#include +#include + +#include +#include + +using namespace android; + +int main(int argc, char** argv) +{ + EGLint configAttribs[] = { + EGL_DEPTH_SIZE, 0, + EGL_NONE + }; + + EGLint majorVersion; + EGLint minorVersion; + EGLContext context; + EGLConfig config; + EGLSurface surface; + EGLint w, h; + EGLDisplay dpy; + + dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(dpy, &majorVersion, &minorVersion); + + EGLNativeWindowType window = android_createDisplaySurface(); + + 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; + } + + surface = eglCreateWindowSurface(dpy, config, window, NULL); + context = eglCreateContext(dpy, config, NULL, NULL); + eglMakeCurrent(dpy, surface, surface, context); + eglQuerySurface(dpy, surface, EGL_WIDTH, &w); + eglQuerySurface(dpy, surface, EGL_HEIGHT, &h); + GLint dim = w