diff options
Diffstat (limited to 'progs/egl')
-rw-r--r-- | progs/egl/Makefile | 6 | ||||
-rw-r--r-- | progs/egl/demo1.c | 1 | ||||
-rw-r--r-- | progs/egl/demo2.c | 14 | ||||
-rw-r--r-- | progs/egl/demo3.c | 15 | ||||
-rw-r--r-- | progs/egl/eglgears.c | 1 | ||||
-rw-r--r-- | progs/egl/eglinfo.c | 30 | ||||
-rw-r--r-- | progs/egl/egltri.c | 1 | ||||
-rw-r--r-- | progs/egl/xegl_tri.c | 4 | ||||
-rw-r--r-- | progs/egl/xeglbindtex.c | 474 | ||||
-rw-r--r-- | progs/egl/xeglgears.c | 2 | ||||
-rw-r--r-- | progs/egl/xeglthreads.c | 4 |
11 files changed, 50 insertions, 502 deletions
diff --git a/progs/egl/Makefile b/progs/egl/Makefile index ff9a858c56..0ddb2cabb4 100644 --- a/progs/egl/Makefile +++ b/progs/egl/Makefile @@ -20,7 +20,6 @@ PROGRAMS = \ eglgears \ eglscreen \ peglgears \ - xeglbindtex \ xeglgears \ xeglthreads \ xegl_tri @@ -46,7 +45,7 @@ egltri: egltri.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) eglinfo: eglinfo.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) eglgears: eglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) @@ -57,9 +56,6 @@ eglscreen: eglscreen.o $(HEADERS) $(LIB_DEP) peglgears: peglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) $(LIBDRM_LIB) -xeglbindtex: xeglbindtex.o $(HEADERS) $(LIB_DEP) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lX11 - xeglgears: xeglgears.o $(HEADERS) $(LIB_DEP) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS) -lX11 diff --git a/progs/egl/demo1.c b/progs/egl/demo1.c index 34a516e72f..d892734ee5 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 3994656721..b9e92f62ac 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 0665fd0516..64b9ee652c 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 2d9b8cac7f..63490953ae 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/eglinfo.c b/progs/egl/eglinfo.c index 4486916e95..9664667a68 100644 --- a/progs/egl/eglinfo.c +++ b/progs/egl/eglinfo.c @@ -49,16 +49,15 @@ PrintConfigs(EGLDisplay d) eglGetConfigs(d, configs, MAX_CONFIGS, &numConfigs); printf("Configurations:\n"); - printf(" bf lv d st colorbuffer dp st ms vis supported\n"); - printf(" id sz l b ro r g b a th cl ns b id surfaces \n"); - printf("--------------------------------------------------------\n"); + printf(" bf lv colorbuffer dp st ms vis cav bi renderable supported\n"); + printf(" id sz l r g b a th cl ns b id eat nd gl es es2 vg surfaces \n"); + printf("---------------------------------------------------------------------\n"); for (i = 0; i < numConfigs; i++) { EGLint id, size, level; EGLint red, green, blue, alpha; EGLint depth, stencil; - EGLint surfaces; - EGLint doubleBuf = 1, stereo = 0; - EGLint vid; + EGLint renderable, surfaces; + EGLint vid, caveat, bindRgb, bindRgba; EGLint samples, sampleBuffers; char surfString[100] = ""; @@ -73,6 +72,11 @@ PrintConfigs(EGLDisplay d) eglGetConfigAttrib(d, configs[i], EGL_DEPTH_SIZE, &depth); eglGetConfigAttrib(d, configs[i], EGL_STENCIL_SIZE, &stencil); eglGetConfigAttrib(d, configs[i], EGL_NATIVE_VISUAL_ID, &vid); + + eglGetConfigAttrib(d, configs[i], EGL_CONFIG_CAVEAT, &caveat); + eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGB, &bindRgb); + eglGetConfigAttrib(d, configs[i], EGL_BIND_TO_TEXTURE_RGBA, &bindRgba); + eglGetConfigAttrib(d, configs[i], EGL_RENDERABLE_TYPE, &renderable); eglGetConfigAttrib(d, configs[i], EGL_SURFACE_TYPE, &surfaces); eglGetConfigAttrib(d, configs[i], EGL_SAMPLES, &samples); @@ -91,13 +95,19 @@ PrintConfigs(EGLDisplay d) if (strlen(surfString) > 0) surfString[strlen(surfString) - 1] = 0; - printf("0x%02x %2d %2d %c %c %2d %2d %2d %2d %2d %2d %2d%2d 0x%02x %-12s\n", + printf("0x%02x %2d %2d %2d %2d %2d %2d %2d %2d %2d%2d 0x%03x ", id, size, level, - doubleBuf ? 'y' : '.', - stereo ? 'y' : '.', red, green, blue, alpha, depth, stencil, - samples, sampleBuffers, vid, surfString); + samples, sampleBuffers, vid); + printf(" %c %c %c %c %c %c %s\n", + (caveat != EGL_NONE) ? 'y' : ' ', + (bindRgba) ? 'a' : (bindRgb) ? 'y' : ' ', + (renderable & EGL_OPENGL_BIT) ? 'y' : ' ', + (renderable & EGL_OPENGL_ES_BIT) ? 'y' : ' ', + (renderable & EGL_OPENGL_ES2_BIT) ? 'y' : ' ', + (renderable & EGL_OPENVG_BIT) ? 'y' : ' ', + surfString); } } diff --git a/progs/egl/egltri.c b/progs/egl/egltri.c index 9bbc3cddaf..006e06eb03 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"); diff --git a/progs/egl/xegl_tri.c b/progs/egl/xegl_tri.c index 65f352ddfa..1f1a005a21 100644 --- a/progs/egl/xegl_tri.c +++ b/progs/egl/xegl_tri.c @@ -120,6 +120,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1, EGL_DEPTH_SIZE, 1, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, EGL_NONE }; @@ -138,7 +139,8 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy, scrnum = DefaultScreen( x_dpy ); root = RootWindow( x_dpy, scrnum ); - if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { + if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) || + !num_configs) { printf("Error: couldn't get an EGL visual config\n"); exit(1); } diff --git a/progs/egl/xeglbindtex.c b/progs/egl/xeglbindtex.c deleted file mode 100644 index fdd9fe2b87..0000000000 --- a/progs/egl/xeglbindtex.c +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Simple demo for eglBindTexImage. Based on xegl_tri.c by - * - * Copyright (C) 2008 Brian Paul 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 - * BRIAN PAUL 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. - */ - -/* - * The spec says that eglBindTexImage supports only OpenGL ES context, but this - * demo uses OpenGL context. Keep in mind that this is non-standard. - */ - -#include <math.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/keysym.h> -#include <GL/gl.h> -#include <EGL/egl.h> - -static EGLDisplay dpy; -static EGLContext ctx_win, ctx_pbuf; -static EGLSurface surf_win, surf_pbuf; -static GLuint tex_pbuf; - -static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0; -static GLboolean blend = GL_TRUE; -static GLuint color_flow; - -static void -make_pbuffer(int width, int height) -{ - static const EGLint config_attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE, - EGL_NONE - }; - EGLint pbuf_attribs[] = { - EGL_WIDTH, width, - EGL_HEIGHT, height, - EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, - EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, - EGL_NONE - }; - EGLConfig config; - EGLint num_configs; - - if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs)) { - printf("Error: couldn't get an EGL visual config for pbuffer\n"); - exit(1); - } - - eglBindAPI(EGL_OPENGL_API); - ctx_pbuf = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL ); - surf_pbuf = eglCreatePbufferSurface(dpy, config, pbuf_attribs); - if (surf_pbuf == EGL_NO_SURFACE) { - printf("failed to allocate pbuffer\n"); - exit(1); - } - - glGenTextures(1, &tex_pbuf); -} - -static void -use_pbuffer(void) -{ - static int initialized; - - eglMakeCurrent(dpy, surf_pbuf, surf_pbuf, ctx_pbuf); - if (!initialized) { - EGLint width, height; - GLfloat ar; - - initialized = 1; - - eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &width); - eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &height); - ar = (GLfloat) width / (GLfloat) height; - - glViewport(0, 0, (GLint) width, (GLint) height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-ar, ar, -1, 1, 1.0, 10.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - /* y-inverted */ - glScalef(1.0, -1.0, 1.0); - - glTranslatef(0.0, 0.0, -5.0); - - glClearColor(0.2, 0.2, 0.2, 0.0); - } -} - -static void -make_window(Display *x_dpy, const char *name, - int x, int y, int width, int height, - Window *winRet) -{ - static const EGLint attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_DEPTH_SIZE, 8, - EGL_NONE - }; - - int scrnum; - XSetWindowAttributes attr; - unsigned long mask; - Window root; - Window win; - XVisualInfo *visInfo, visTemplate; - int num_visuals; - EGLConfig config; - EGLint num_configs, vid; - - scrnum = DefaultScreen( x_dpy ); - root = RootWindow( x_dpy, scrnum ); - - if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs)) { - printf("Error: couldn't get an EGL visual config\n"); - exit(1); - } - - if (!eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { - printf("Error: eglGetConfigAttrib() failed\n"); - exit(1); - } - - /* The X window visual must match the EGL config */ - visTemplate.visualid = vid; - visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); - if (!visInfo) { - printf("Error: couldn't get X visual\n"); - exit(1); - } - - /* window attributes */ - attr.background_pixel = 0; - attr.border_pixel = 0; - attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); - attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - attr.override_redirect = 0; - mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; - - win = XCreateWindow( x_dpy, root, 0, 0, width, height, - 0, visInfo->depth, InputOutput, - visInfo->visual, mask, &attr ); - - /* set hints and properties */ - { - XSizeHints sizehints; - sizehints.x = x; - sizehints.y = y; - sizehints.width = width; - sizehints.height = height; - sizehints.flags = USSize | USPosition; - XSetNormalHints(x_dpy, win, &sizehints); - XSetStandardProperties(x_dpy, win, name, name, - None, (char **)NULL, 0, &sizehints); - } - - eglBindAPI(EGL_OPENGL_API); - ctx_win = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL ); - if (!ctx_win) { - printf("Error: glXCreateContext failed\n"); - exit(1); - } - - surf_win = eglCreateWindowSurface(dpy, config, win, NULL); - - XFree(visInfo); - - *winRet = win; -} - -static void -use_window(void) -{ - static int initialized; - - eglMakeCurrent(dpy, surf_win, surf_win, ctx_win); - if (!initialized) { - initialized = 1; - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, tex_pbuf); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } -} - -static void -draw_triangle(void) -{ - static const GLfloat verts[3][2] = { - { -3, -3 }, - { 3, -3 }, - { 0, 3 } - }; - GLfloat colors[3][3] = { - { 1, 0, 0 }, - { 0, 1, 0 }, - { 0, 0, 1 } - }; - GLint i; - - /* flow the color */ - for (i = 0; i < 3; i++) { - GLint first = (i + color_flow / 256) % 3; - GLint second = (first + 1) % 3; - GLint third = (second + 1) % 3; - GLfloat c = (color_flow % 256) / 256.0f; - - c = c * c * c; - colors[i][first] = 1.0f - c; - colors[i][second] = c; - colors[i][third] = 0.0f; - } - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glVertexPointer(2, GL_FLOAT, 0, verts); - glColorPointer(3, GL_FLOAT, 0, colors); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - - glDrawArrays(GL_TRIANGLES, 0, 3); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - -static void -draw_textured_cube(void) -{ - static const GLfloat verts[][2] = { - { -4, -4 }, - { 4, -4 }, - { 4, 4 }, - { -4, 4 } - }; - static const GLfloat colors[][4] = { - { 1, 1, 1, 0.5 }, - { 1, 1, 1, 0.5 }, - { 1, 1, 1, 0.5 }, - { 1, 1, 1, 0.5 } - }; - static const GLfloat texs[][2] = { - { 0, 0 }, - { 1, 0 }, - { 1, 1 }, - { 0, 1 } - }; - static const GLfloat xforms[6][4] = { - { 0, 0, 1, 0 }, - { 90, 0, 1, 0 }, - { 180, 0, 1, 0 }, - { 270, 0, 1, 0 }, - { 90, 1, 0, 0 }, - { -90, 1, 0, 0 } - }; - GLint i; - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - if (blend) { - glDisable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - } else { - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - } - - glVertexPointer(2, GL_FLOAT, 0, verts); - glColorPointer(4, GL_FLOAT, 0, colors); - glTexCoordPointer(2, GL_FLOAT, 0, texs); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - - for (i = 0; i < 6; i++) { - glPushMatrix(); - glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]); - glTranslatef(0, 0, 4.1); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glPopMatrix(); - } - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); -} - -static void -draw(void) -{ - use_pbuffer(); - draw_triangle(); - - use_window(); - - eglBindTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER); - - glPushMatrix(); - glRotatef(view_rotx, 1, 0, 0); - glRotatef(view_roty, 0, 1, 0); - glRotatef(view_rotz, 0, 0, 1); - - draw_textured_cube(); - - glPopMatrix(); - - eglReleaseTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER); -} - -/* new window size or exposure */ -static void -reshape(int width, int height) -{ - GLfloat ar = (GLfloat) width / (GLfloat) height; - - use_window(); - - glViewport(0, 0, (GLint) width, (GLint) height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(-ar, ar, -1, 1, 5.0, 60.0); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0, 0.0, -40.0); -} - -static void -event_loop(Display *x_dpy, Window win) -{ - while (1) { - int redraw = 1; - - if (XPending(x_dpy) > 0) { - XEvent event; - XNextEvent(x_dpy, &event); - - switch (event.type) { - case Expose: - redraw = 1; - break; - case ConfigureNotify: - reshape(event.xconfigure.width, event.xconfigure.height); - break; - case KeyPress: - { - char buffer[10]; - int r, code; - code = XLookupKeysym(&event.xkey, 0); - if (code == XK_Left) { - view_roty += 5.0; - } - else if (code == XK_Right) { - view_roty -= 5.0; - } - else if (code == XK_Up) { - view_rotx += 5.0; - } - else if (code == XK_Down) { - view_rotx -= 5.0; - } - else if (code == XK_b) { - blend = !blend; - } - else { - r = XLookupString(&event.xkey, buffer, sizeof(buffer), - NULL, NULL); - if (buffer[0] == 27) { - /* escape */ - return; - } - } - } - redraw = 1; - break; - default: - ; /*no-op*/ - } - } - - if (redraw) { - view_rotx += 1.0; - view_roty += 2.0; - view_rotz += 1.5; - color_flow += 20; - draw(); - eglSwapBuffers(dpy, surf_win); - } - } -} - -int -main(int argc, char *argv[]) -{ - const int winWidth = 300, winHeight = 300; - Display *x_dpy; - Window win; - char *dpyName = NULL; - EGLint egl_major, egl_minor; - const char *s; - - x_dpy = XOpenDisplay(dpyName); - if (!x_dpy) { - printf("Error: couldn't open display %s\n", - dpyName ? dpyName : getenv("DISPLAY")); - return -1; - } - - dpy = eglGetDisplay(x_dpy); - if (!dpy) { - printf("Error: eglGetDisplay() failed\n"); - return -1; - } - - if (!eglInitialize(dpy, &egl_major, &egl_minor)) { - printf("Error: eglInitialize() failed\n"); - return -1; - } - - s = eglQueryString(dpy, EGL_VERSION); - printf("EGL_VERSION = %s\n", s); - - make_window(x_dpy, "color flow", 0, 0, winWidth, winHeight, &win); - make_pbuffer(winWidth, winHeight); - - XMapWindow(x_dpy, win); - - reshape(winWidth, winHeight); - event_loop(x_dpy, win); - - glDeleteTextures(1, &tex_pbuf); - - eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglTerminate(dpy); - - XDestroyWindow(x_dpy, win); - XCloseDisplay(x_dpy); - - return 0; -} diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c index 614a625603..9fdf474244 100644 --- a/progs/egl/xeglgears.c +++ b/progs/egl/xeglgears.c @@ -604,7 +604,7 @@ event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h) break; case EGL_PBUFFER_BIT: eglWaitClient(); - if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix)) + if (!eglCopyBuffers(eman->dpy, eman->pbuf, eman->xpix)) break; /* fall through */ case EGL_PIXMAP_BIT: diff --git a/progs/egl/xeglthreads.c b/progs/egl/xeglthreads.c index 508dbc0943..5787faecb9 100644 --- a/progs/egl/xeglthreads.c +++ b/progs/egl/xeglthreads.c @@ -467,6 +467,7 @@ create_window(struct winthread *wt, EGLContext shareCtx) EGL_GREEN_SIZE, 1, EGL_BLUE_SIZE, 1, EGL_DEPTH_SIZE, 1, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, EGL_NONE }; EGLConfig config; EGLint num_configs; @@ -484,7 +485,8 @@ create_window(struct winthread *wt, EGLContext shareCtx) scrnum = DefaultScreen(wt->Dpy); root = RootWindow(wt->Dpy, scrnum); - if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs)) { + if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs) || + !num_configs) { Error("Unable to choose an EGL config"); } |