From 472a6019665094c18fc47624b343ddc8c90f102c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 4 Jan 2010 13:32:50 +0800 Subject: [PATCH] progs/egl: Fix screen surface demos. Set the screen surface size to the mode size, as the spec requires the screen surface size to be larger than the mode size. Besides, bind the API to OpenGL as they are written in it. Signed-off-by: Chia-I Wu --- progs/egl/demo1.c | 1 + progs/egl/demo2.c | 14 +++++++++----- progs/egl/demo3.c | 15 ++++++++++----- progs/egl/eglgears.c | 1 + progs/egl/egltri.c | 1 + 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c index 34a516e72fc..d892734ee55 100644 --- a/progs/egl/demo1.c +++ b/progs/egl/demo1.c @@ -114,6 +114,7 @@ main(int argc, char *argv[]) PrintConfigs(d, configs, numConfigs); + eglBindAPI(EGL_OPENGL_API); ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); if (ctx == EGL_NO_CONTEXT) { printf("failed to create context\n"); diff --git a/progs/egl/demo2.c b/progs/egl/demo2.c index 3994656721f..b9e92f62ac2 100644 --- a/progs/egl/demo2.c +++ b/progs/egl/demo2.c @@ -111,11 +111,7 @@ main(int argc, char *argv[]) EGL_HEIGHT, 500, EGL_NONE }; - const EGLint screenAttribs[] = { - EGL_WIDTH, 1024, - EGL_HEIGHT, 768, - EGL_NONE - }; + EGLint screenAttribs[32]; EGLModeMESA mode; EGLScreenMESA screen; EGLint count; @@ -149,6 +145,7 @@ main(int argc, char *argv[]) eglGetScreensMESA(d, &screen, 1, &count); eglGetModesMESA(d, screen, &mode, 1, &count); + eglBindAPI(EGL_OPENGL_API); ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); if (ctx == EGL_NO_CONTEXT) { printf("failed to create context\n"); @@ -169,6 +166,13 @@ main(int argc, char *argv[]) b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + i = 0; + screenAttribs[i++] = EGL_WIDTH; + eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]); + screenAttribs[i++] = EGL_HEIGHT; + eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]); + screenAttribs[i] = EGL_NONE; + screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs); if (screen_surf == EGL_NO_SURFACE) { printf("failed to create screen surface\n"); diff --git a/progs/egl/demo3.c b/progs/egl/demo3.c index 0665fd0516e..64b9ee652cd 100644 --- a/progs/egl/demo3.c +++ b/progs/egl/demo3.c @@ -564,11 +564,8 @@ main(int argc, char *argv[]) EGLint numConfigs, count; EGLBoolean b; const GLubyte *bitmap; - const EGLint screenAttribs[] = { - EGL_WIDTH, 1024, - EGL_HEIGHT, 768, - EGL_NONE - }; + EGLint screenAttribs[32]; + EGLint i; EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY); assert(d); @@ -590,12 +587,20 @@ main(int argc, char *argv[]) eglGetScreensMESA(d, &screen, 1, &count); eglGetModesMESA(d, screen, &mode, 1, &count); + eglBindAPI(EGL_OPENGL_API); ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); if (ctx == EGL_NO_CONTEXT) { printf("failed to create context\n"); return 0; } + i = 0; + screenAttribs[i++] = EGL_WIDTH; + eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]); + screenAttribs[i++] = EGL_HEIGHT; + eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]); + screenAttribs[i] = EGL_NONE; + screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs); if (screen_surf == EGL_NO_SURFACE) { printf("failed to create screen surface\n"); diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c index 2d9b8cac7f7..63490953aee 100644 --- a/progs/egl/eglgears.c +++ b/progs/egl/eglgears.c @@ -426,6 +426,7 @@ main(int argc, char *argv[]) } printf("eglgears: Using screen mode/size %d: %d x %d\n", chosenMode, width, height); + eglBindAPI(EGL_OPENGL_API); ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); if (ctx == EGL_NO_CONTEXT) { printf("eglgears: failed to create context\n"); diff --git a/progs/egl/egltri.c b/progs/egl/egltri.c index 9bbc3cddaf1..006e06eb03e 100644 --- a/progs/egl/egltri.c +++ b/progs/egl/egltri.c @@ -208,6 +208,7 @@ int main(int argc, char *argv[]) } printf("egltri: Using screen mode/size %d: %d x %d\n", chosenMode, width, height); + eglBindAPI(EGL_OPENGL_API); ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL); if (ctx == EGL_NO_CONTEXT) { printf("egltri: failed to create context\n"); -- 2.30.2