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 Original line Diff line number Diff line
@@ -2,7 +2,7 @@


LOCAL_PATH:= $(call my-dir)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
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_SHARED_LIBRARIES := libEGL libGLESv1_CM libui
LOCAL_MODULE:= angeles
LOCAL_MODULE:= angeles
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := optional
+19 −58
Original line number Original line Diff line number Diff line
@@ -52,6 +52,11 @@
#include <EGL/egl.h>
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <GLES/gl.h>


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

using namespace android;

#include "app.h"
#include "app.h"




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


static int initGraphics()
static int initGraphics()
{
{
    EGLint s_configAttribs[] = {
    EGLint configAttribs[] = {
         EGL_RED_SIZE,       5,
         EGL_GREEN_SIZE,     6,
         EGL_BLUE_SIZE,      5,
 #if 1
         EGL_DEPTH_SIZE, 16,
         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
         EGL_NONE
     };
     };
     
     
     EGLint numConfigs = -1;
     EGLint n = 0;
     EGLint majorVersion;
     EGLint majorVersion;
     EGLint minorVersion;
     EGLint minorVersion;
     EGLConfig config;
     EGLContext context;
     EGLContext context;
     EGLConfig config;
     EGLSurface surface;
     EGLSurface surface;
     
     EGLint w, h;
     EGLDisplay dpy;
     EGLDisplay dpy;


     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     egl_error("eglGetDisplay");
     fprintf(stderr,"dpy = 0x%08x\n", (unsigned) dpy);
     
     eglInitialize(dpy, &majorVersion, &minorVersion);
     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);
     status_t err = EGLUtils::selectConfigForNativeWindow(
     //egl_error("eglGetConfigs");
             dpy, configAttribs, window, &config);
     //fprintf(stderr,"num configs %d\n", numConfigs);     
     if (err) {
     //eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
         fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n");
     //egl_error("eglChooseConfig");
         return 0;
     }


     surface = eglCreateWindowSurface(dpy, config,
     surface = eglCreateWindowSurface(dpy, config, window, NULL);
             android_createDisplaySurface(), NULL);
     egl_error("eglCreateWindowSurface");
     egl_error("eglCreateWindowSurface");


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


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


using namespace android;
using namespace android;


@@ -36,48 +37,27 @@ int main(int argc, char** argv)
         EGL_NONE
         EGL_NONE
     };
     };
     
     
     EGLint numConfigs = -1, n=0;
     EGLint majorVersion;
     EGLint majorVersion;
     EGLint minorVersion;
     EGLint minorVersion;
     EGLConfig config;
     EGLContext context;
     EGLContext context;
     EGLConfig config;
     EGLSurface surface;
     EGLSurface surface;
     EGLint w, h;
     EGLint w, h;
     
     EGLDisplay dpy;
     EGLDisplay dpy;


     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(dpy, &majorVersion, &minorVersion);
     eglInitialize(dpy, &majorVersion, &minorVersion);
          
          
     // Get all the "potential match" configs...
     EGLNativeWindowType window = android_createDisplaySurface();
     eglGetConfigs(dpy, NULL, 0, &numConfigs);
     
     EGLConfig* const configs = (EGLConfig*)malloc(sizeof(EGLConfig)*numConfigs);
     status_t err = EGLUtils::selectConfigForNativeWindow(
     eglChooseConfig(dpy, configAttribs, configs, numConfigs, &n);
             dpy, configAttribs, window, &config);
     config = configs[0];
     if (err) {
     if (n > 1) {
         fprintf(stderr, "couldn't find an EGLConfig matching the screen format\n");
         // if there is more than one candidate, go through the list
         return 0;
         // 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);


     surface = eglCreateWindowSurface(dpy, config,
     surface = eglCreateWindowSurface(dpy, config, window, NULL);
             android_createDisplaySurface(), NULL);
     context = eglCreateContext(dpy, config, NULL, NULL);
     context = eglCreateContext(dpy, config, NULL, NULL);
     eglMakeCurrent(dpy, surface, surface, context);   
     eglMakeCurrent(dpy, surface, surface, context);   
     eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
     eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
+3 −1
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
include $(CLEAR_VARS)


LOCAL_SRC_FILES:= \
LOCAL_SRC_FILES:= \
	filter.c
	filter.cpp


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


LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_TAGS := optional


LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES

include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
+10 −3
Original line number Original line Diff line number Diff line
@@ -5,6 +5,11 @@
#include <GLES/gl.h>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <GLES/glext.h>


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

using namespace android;

int main(int argc, char** argv)
int main(int argc, char** argv)
{
{
    if (argc!=2 && argc!=3) {
    if (argc!=2 && argc!=3) {
@@ -34,12 +39,14 @@ int main(int argc, char** argv)


     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
     eglInitialize(dpy, &majorVersion, &minorVersion);
     eglInitialize(dpy, &majorVersion, &minorVersion);
     eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
     if (!usePbuffer) {
     if (!usePbuffer) {
         surface = eglCreateWindowSurface(dpy, config,
         EGLNativeWindowType window = android_createDisplaySurface();
                 android_createDisplaySurface(), NULL);
         surface = eglCreateWindowSurface(dpy, config, window, NULL);
         EGLUtils::selectConfigForNativeWindow(
                 dpy, s_configAttribs, window, &config);
     } else {
     } else {
         printf("using pbuffer\n");
         printf("using pbuffer\n");
         eglChooseConfig(dpy, s_configAttribs, &config, 1, &numConfigs);
         EGLint attribs[] = { EGL_WIDTH, 320, EGL_HEIGHT, 480, EGL_NONE };
         EGLint attribs[] = { EGL_WIDTH, 320, EGL_HEIGHT, 480, EGL_NONE };
         surface = eglCreatePbufferSurface(dpy, config, attribs);
         surface = eglCreatePbufferSurface(dpy, config, attribs);
         if (surface == EGL_NO_SURFACE) {
         if (surface == EGL_NO_SURFACE) {
Loading