Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 653870d5 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

update most gl tests to use EGLUtils

parent 6cf50a77
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+19 −58
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@
#include <EGL/egl.h>
#include <GLES/gl.h>

#include <ui/FramebufferNativeWindow.h>
#include <ui/EGLUtils.h>

using namespace android;

#include "app.h"


@@ -115,76 +120,32 @@ static void checkEGLErrors()

static int initGraphics()
{
    EGLint s_configAttribs[] = {
         EGL_RED_SIZE,       5,
         EGL_GREEN_SIZE,     6,
         EGL_BLUE_SIZE,      5,
 #if 1
    EGLint configAttribs[] = {
         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;
     EGLConfig config;
     EGLSurface surface;
     
     EGLint w, h;
     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<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;
             }
         }
     }
     free(configs);
          
     EGLNativeWindowType window = android_createDisplaySurface();
     
     //eglGetConfigs(dpy, NULL, 0, &numConfigs);
     //egl_error("eglGetConfigs");
     //fprintf(stderr,"num configs %d\n", numConfigs);     
     //eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
     //egl_error("eglChooseConfig");
     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,
             android_createDisplaySurface(), NULL);
     surface = eglCreateWindowSurface(dpy, config, window, NULL);
     egl_error("eglCreateWindowSurface");

     fprintf(stderr,"surface = %p\n", surface);
+11 −31
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@

#include <utils/StopWatch.h>
#include <ui/FramebufferNativeWindow.h>
#include <ui/EGLUtils.h>

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);
          
     // 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<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;
             }
         }
     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;
     }
     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);
+3 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
	filter.c
	filter.cpp

LOCAL_SHARED_LIBRARIES := \
	libcutils \
@@ -14,4 +14,6 @@ LOCAL_MODULE:= test-opengl-filter

LOCAL_MODULE_TAGS := optional

LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES

include $(BUILD_EXECUTABLE)
+10 −3
Original line number Diff line number Diff line
@@ -5,6 +5,11 @@
#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)
{
    if (argc!=2 && argc!=3) {
@@ -34,12 +39,14 @@ int main(int argc, char** argv)

     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);
         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) {
Loading