1 This makes it possible to build the demos against opengl
2 implementations other than Mesa
4 Signed-off-by: Spenser Gilliland <spenser@gillilanding.com>
6 Index: mesa3d-demos-8.1.0/src/egl/eglut/eglut.c
7 ===================================================================
8 --- mesa3d-demos-8.1.0.orig/src/egl/eglut/eglut.c
9 +++ mesa3d-demos-8.1.0/src/egl/eglut/eglut.c
10 @@ -76,8 +76,9 @@ _eglutNow(void)
12 _eglutDestroyWindow(struct eglut_window *win)
14 - if (_eglut->surface_type != EGL_PBUFFER_BIT &&
15 - _eglut->surface_type != EGL_SCREEN_BIT_MESA)
17 + if (_eglut->surface_type == EGL_WINDOW_BIT ||
18 + _eglut->surface_type == EGL_PIXMAP_BIT)
19 eglDestroySurface(_eglut->dpy, win->surface);
21 _eglutNativeFiniWindow(win);
22 @@ -175,7 +176,9 @@ _eglutCreateWindow(const char *title, in
23 win->config, win->native.u.pixmap, NULL);
26 +#ifdef EGL_MESA_screen_surface
27 case EGL_SCREEN_BIT_MESA:
29 win->surface = win->native.u.surface;
32 @@ -289,8 +292,10 @@ eglutDestroyWindow(int win)
33 if (window->index != win)
36 +#ifdef EGL_MESA_screen_surface
37 /* XXX it causes some bug in st/egl KMS backend */
38 if ( _eglut->surface_type != EGL_SCREEN_BIT_MESA)
40 eglMakeCurrent(_eglut->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
42 _eglutDestroyWindow(_eglut->current);
43 Index: mesa3d-demos-8.1.0/src/egl/eglut/eglut_screen.c
44 ===================================================================
45 --- mesa3d-demos-8.1.0.orig/src/egl/eglut/eglut_screen.c
46 +++ mesa3d-demos-8.1.0/src/egl/eglut/eglut_screen.c
51 +#ifdef EGL_MESA_screen_surface
52 static EGLScreenMESA kms_screen;
53 static EGLModeMESA kms_mode;
54 static EGLint kms_width, kms_height;
58 _eglutNativeInitDisplay(void)
60 +#ifdef EGL_MESA_screen_surface
61 _eglut->native_dpy = EGL_DEFAULT_DISPLAY;
62 _eglut->surface_type = EGL_SCREEN_BIT_MESA;
67 _eglutNativeFiniDisplay(void)
69 +#ifdef EGL_MESA_screen_surface
77 +#ifdef EGL_MESA_screen_surface
81 @@ -94,19 +101,23 @@ init_kms(void)
88 _eglutNativeInitWindow(struct eglut_window *win, const char *title,
89 int x, int y, int w, int h)
91 +#ifdef EGL_MESA_screen_surface
92 EGLint surf_attribs[16];
97 exts = eglQueryString(_eglut->dpy, EGL_EXTENSIONS);
98 if (!exts || !strstr(exts, "EGL_MESA_screen_surface"))
99 _eglutFatal("EGL_MESA_screen_surface is not supported\n");
101 +#ifdef EGL_MESA_screen_surface
105 @@ -128,14 +139,17 @@ _eglutNativeInitWindow(struct eglut_wind
107 win->native.width = kms_width;
108 win->native.height = kms_height;
113 _eglutNativeFiniWindow(struct eglut_window *win)
115 +#ifdef EGL_MESA_screen_surface
116 eglShowScreenSurfaceMESA(_eglut->dpy,
117 kms_screen, EGL_NO_SURFACE, 0);
118 eglDestroySurface(_eglut->dpy, win->native.u.surface);
123 Index: mesa3d-demos-8.1.0/src/egl/opengl/demo1.c
124 ===================================================================
125 --- mesa3d-demos-8.1.0.orig/src/egl/opengl/demo1.c
126 +++ mesa3d-demos-8.1.0/src/egl/opengl/demo1.c
129 TestScreens(EGLDisplay dpy)
131 +#ifdef EGL_MESA_screen_surface
133 EGLScreenMESA screens[MAX];
135 @@ -28,6 +29,7 @@ TestScreens(EGLDisplay dpy)
136 for (i = 0; i < numScreens; i++) {
137 printf(" Screen %d handle: %d\n", i, (int) screens[i]);
143 Index: mesa3d-demos-8.1.0/src/egl/opengl/demo2.c
144 ===================================================================
145 --- mesa3d-demos-8.1.0.orig/src/egl/opengl/demo2.c
146 +++ mesa3d-demos-8.1.0/src/egl/opengl/demo2.c
149 /*#define FRONTBUFFER*/
151 +#ifdef EGL_MESA_screen_surface
152 static void _subset_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2,
153 GLfloat r, GLfloat g, GLfloat b)
155 @@ -95,12 +96,13 @@ TestScreens(EGLDisplay dpy)
156 printf(" Screen %d handle: %d\n", i, (int) screens[i]);
163 main(int argc, char *argv[])
166 +#ifdef EGL_MESA_screen_surface
168 EGLSurface pbuffer, screen_surf;
169 EGLConfig configs[10];
170 @@ -115,6 +117,7 @@ main(int argc, char *argv[])
172 EGLScreenMESA screen;
176 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
178 @@ -132,6 +135,7 @@ main(int argc, char *argv[])
182 +#ifdef EGL_MESA_screen_surface
183 eglGetConfigs(d, configs, 10, &numConfigs);
184 printf("Got %d EGL configs:\n", numConfigs);
185 for (i = 0; i < numConfigs; i++) {
186 @@ -211,6 +215,7 @@ main(int argc, char *argv[])
187 eglDestroySurface(d, pbuffer);
188 eglDestroyContext(d, ctx);
194 Index: mesa3d-demos-8.1.0/src/egl/opengl/demo3.c
195 ===================================================================
196 --- mesa3d-demos-8.1.0.orig/src/egl/opengl/demo3.c
197 +++ mesa3d-demos-8.1.0/src/egl/opengl/demo3.c
198 @@ -46,7 +46,7 @@ GLubyte OpenGL_bits[] = {
199 0x3e, 0x00, 0x00, 0xf8, 0x0c, 0x00,
203 +#ifdef EGL_MESA_screen_surface
204 static void Init(void)
207 @@ -551,11 +551,13 @@ write_ppm(const char *filename, const GL
214 main(int argc, char *argv[])
217 +#ifdef EGL_MESA_screen_surface
219 EGLSurface screen_surf;
220 EGLConfig configs[10];
221 @@ -566,6 +568,7 @@ main(int argc, char *argv[])
222 const GLubyte *bitmap;
223 EGLint screenAttribs[32];
227 EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
229 @@ -583,6 +586,7 @@ main(int argc, char *argv[])
233 +#ifdef EGL_MESA_screen_surface
234 eglGetConfigs(d, configs, 10, &numConfigs);
235 eglGetScreensMESA(d, &screen, 1, &count);
236 eglGetModesMESA(d, screen, &mode, 1, &count);
237 @@ -642,6 +646,7 @@ main(int argc, char *argv[])
238 eglDestroySurface(d, screen_surf);
239 eglDestroyContext(d, ctx);