blob: b21d54268a8c8a0f182c51711c70424188614600 [file] [log] [blame]
Benjamin Franzkeaabdce02011-01-15 00:40:17 +01001/*
2 * Copyright © 2011 Benjamin Franzke
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010026#include <stdbool.h>
27#include <math.h>
28#include <assert.h>
Pekka Paalanen88e60fc2011-12-13 12:09:09 +020029#include <signal.h>
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010030
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010031#include <wayland-client.h>
Kristian Høgsberga495a5e2011-02-04 15:31:33 -050032#include <wayland-egl.h>
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010033
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010034#include <GLES2/gl2.h>
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010035#include <EGL/egl.h>
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010036
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +030037struct window;
38
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010039struct display {
40 struct wl_display *display;
Kristian Høgsberga495a5e2011-02-04 15:31:33 -050041 struct wl_compositor *compositor;
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -040042 struct wl_shell *shell;
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +030043 struct wl_input_device *input;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010044 struct {
45 EGLDisplay dpy;
46 EGLContext ctx;
Kristian Høgsberga495a5e2011-02-04 15:31:33 -050047 EGLConfig conf;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010048 } egl;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010049 uint32_t mask;
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +030050 struct window *window;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010051};
52
53struct window {
54 struct display *display;
55 struct {
56 int width, height;
57 } geometry;
58 struct {
59 GLuint fbo;
60 GLuint color_rbo;
61
62 GLuint program;
63 GLuint rotation_uniform;
64
65 GLuint pos;
66 GLuint col;
67 } gl;
Kristian Høgsberga495a5e2011-02-04 15:31:33 -050068
69 struct wl_egl_window *native;
70 struct wl_surface *surface;
Pekka Paalanen9d1613e2011-11-25 12:09:16 +020071 struct wl_shell_surface *shell_surface;
Kristian Høgsberga495a5e2011-02-04 15:31:33 -050072 EGLSurface egl_surface;
Pekka Paalanen2c2c1062011-12-13 14:50:25 +020073 struct wl_callback *callback;
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +030074 int fullscreen, configured;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010075};
76
77static const char *vert_shader_text =
78 "uniform mat4 rotation;\n"
79 "attribute vec4 pos;\n"
80 "attribute vec4 color;\n"
81 "varying vec4 v_color;\n"
82 "void main() {\n"
83 " gl_Position = rotation * pos;\n"
84 " v_color = color;\n"
85 "}\n";
86
87static const char *frag_shader_text =
Kristian Høgsberg1a11fac2011-01-14 20:39:21 -050088 "precision mediump float;\n"
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010089 "varying vec4 v_color;\n"
90 "void main() {\n"
91 " gl_FragColor = v_color;\n"
92 "}\n";
93
94static void
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +030095init_egl(struct display *display, EGLint alpha_size)
Benjamin Franzkeaabdce02011-01-15 00:40:17 +010096{
Kristian Høgsberg1a11fac2011-01-14 20:39:21 -050097 static const EGLint context_attribs[] = {
98 EGL_CONTEXT_CLIENT_VERSION, 2,
99 EGL_NONE
100 };
101
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300102 EGLint config_attribs[] = {
Kristian Høgsberg8e81df42012-01-11 14:24:46 -0500103 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500104 EGL_RED_SIZE, 1,
105 EGL_GREEN_SIZE, 1,
106 EGL_BLUE_SIZE, 1,
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300107 EGL_ALPHA_SIZE, alpha_size,
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500108 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
109 EGL_NONE
110 };
111
112 EGLint major, minor, n;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100113 EGLBoolean ret;
114
Kristian Høgsberg91342c62011-04-14 14:44:58 -0400115 display->egl.dpy = eglGetDisplay(display->display);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100116 assert(display->egl.dpy);
117
118 ret = eglInitialize(display->egl.dpy, &major, &minor);
119 assert(ret == EGL_TRUE);
Kristian Høgsberg1a11fac2011-01-14 20:39:21 -0500120 ret = eglBindAPI(EGL_OPENGL_ES_API);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100121 assert(ret == EGL_TRUE);
122
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500123 assert(eglChooseConfig(display->egl.dpy, config_attribs,
124 &display->egl.conf, 1, &n) && n == 1);
125
126 display->egl.ctx = eglCreateContext(display->egl.dpy,
127 display->egl.conf,
Kristian Høgsberg1a11fac2011-01-14 20:39:21 -0500128 EGL_NO_CONTEXT, context_attribs);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100129 assert(display->egl.ctx);
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500130
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100131}
132
Pekka Paalanen2c2c1062011-12-13 14:50:25 +0200133static void
134fini_egl(struct display *display)
135{
136 /* Required, otherwise segfault in egl_dri2.c: dri2_make_current()
137 * on eglReleaseThread(). */
138 eglMakeCurrent(display->egl.dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
139 EGL_NO_CONTEXT);
140
141 eglTerminate(display->egl.dpy);
142 eglReleaseThread();
143}
144
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100145static GLuint
146create_shader(struct window *window, const char *source, GLenum shader_type)
147{
148 GLuint shader;
149 GLint status;
150
151 shader = glCreateShader(shader_type);
152 assert(shader != 0);
153
154 glShaderSource(shader, 1, (const char **) &source, NULL);
155 glCompileShader(shader);
156
157 glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
158 if (!status) {
159 char log[1000];
160 GLsizei len;
161 glGetShaderInfoLog(shader, 1000, &len, log);
162 fprintf(stderr, "Error: compiling %s: %*s\n",
163 shader_type == GL_VERTEX_SHADER ? "vertex" : "fragment",
164 len, log);
165 exit(1);
166 }
167
168 return shader;
169}
170
171static void
172init_gl(struct window *window)
173{
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100174 GLuint frag, vert;
175 GLint status;
176
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100177 glViewport(0, 0, window->geometry.width, window->geometry.height);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100178
179 frag = create_shader(window, frag_shader_text, GL_FRAGMENT_SHADER);
180 vert = create_shader(window, vert_shader_text, GL_VERTEX_SHADER);
181
182 window->gl.program = glCreateProgram();
183 glAttachShader(window->gl.program, frag);
184 glAttachShader(window->gl.program, vert);
185 glLinkProgram(window->gl.program);
186
187 glGetProgramiv(window->gl.program, GL_LINK_STATUS, &status);
188 if (!status) {
189 char log[1000];
190 GLsizei len;
191 glGetProgramInfoLog(window->gl.program, 1000, &len, log);
192 fprintf(stderr, "Error: linking:\n%*s\n", len, log);
193 exit(1);
194 }
195
196 glUseProgram(window->gl.program);
197
198 window->gl.pos = 0;
199 window->gl.pos = 1;
200
201 glBindAttribLocation(window->gl.program, window->gl.pos, "pos");
202 glBindAttribLocation(window->gl.program, window->gl.col, "color");
203 glLinkProgram(window->gl.program);
204
205 window->gl.rotation_uniform =
206 glGetUniformLocation(window->gl.program, "rotation");
207}
208
209static void
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300210handle_ping(void *data, struct wl_shell_surface *shell_surface,
211 uint32_t serial)
212{
213 wl_shell_surface_pong(shell_surface, serial);
214}
215
216static void
217handle_configure(void *data, struct wl_shell_surface *shell_surface,
218 uint32_t edges, int32_t width, int32_t height)
219{
220 struct window *window = data;
221
222 window->geometry.width = width;
223 window->geometry.height = height;
224 window->configured = 1;
225}
226
227static void
228handle_popup_done(void *data, struct wl_shell_surface *shell_surface)
229{
230}
231
232static const struct wl_shell_surface_listener shell_surface_listener = {
233 handle_ping,
234 handle_configure,
235 handle_popup_done
236};
237
238static void
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100239create_surface(struct window *window)
240{
241 struct display *display = window->display;
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500242 EGLBoolean ret;
Benjamin Franzke65e50512011-05-31 11:36:31 +0200243
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500244 window->surface = wl_compositor_create_surface(display->compositor);
Pekka Paalanen9d1613e2011-11-25 12:09:16 +0200245 window->shell_surface = wl_shell_get_shell_surface(display->shell,
246 window->surface);
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300247
248 wl_shell_surface_add_listener(window->shell_surface,
249 &shell_surface_listener, window);
250
251 if (window->fullscreen) {
252 window->configured = 0;
253 wl_shell_surface_set_fullscreen(window->shell_surface,
254 WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
255 0, NULL);
256
257 while (!window->configured)
258 wl_display_iterate(display->display, display->mask);
259 }
260 else
261 wl_shell_surface_set_toplevel(window->shell_surface);
262
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500263 window->native =
Kristian Høgsberg91342c62011-04-14 14:44:58 -0400264 wl_egl_window_create(window->surface,
Kristian Høgsbergbfb8e612011-02-07 10:30:38 -0500265 window->geometry.width,
Kristian Høgsbergf389cac2011-08-31 16:21:38 -0400266 window->geometry.height);
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500267 window->egl_surface =
268 eglCreateWindowSurface(display->egl.dpy,
269 display->egl.conf,
Kristian Høgsberg8e81df42012-01-11 14:24:46 -0500270 window->native, NULL);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100271
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500272 ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
273 window->egl_surface, window->display->egl.ctx);
274 assert(ret == EGL_TRUE);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100275}
276
Pekka Paalanen2c2c1062011-12-13 14:50:25 +0200277static void
278destroy_surface(struct window *window)
279{
280 wl_egl_window_destroy(window->native);
281
282 wl_shell_surface_destroy(window->shell_surface);
283 wl_surface_destroy(window->surface);
284
285 if (window->callback)
286 wl_callback_destroy(window->callback);
287}
288
Kristian Høgsberg33418202011-08-16 23:01:28 -0400289static const struct wl_callback_listener frame_listener;
290
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100291static void
Kristian Høgsberg33418202011-08-16 23:01:28 -0400292redraw(void *data, struct wl_callback *callback, uint32_t time)
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100293{
294 struct window *window = data;
295 static const GLfloat verts[3][2] = {
296 { -0.5, -0.5 },
297 { 0.5, -0.5 },
298 { 0, 0.5 }
299 };
300 static const GLfloat colors[3][3] = {
301 { 1, 0, 0 },
302 { 0, 1, 0 },
303 { 0, 0, 1 }
304 };
305 GLfloat angle;
306 GLfloat rotation[4][4] = {
307 { 1, 0, 0, 0 },
308 { 0, 1, 0, 0 },
309 { 0, 0, 1, 0 },
310 { 0, 0, 0, 1 }
311 };
312 static const int32_t speed_div = 5;
313 static uint32_t start_time = 0;
314
315 if (start_time == 0)
316 start_time = time;
317
318 angle = ((time-start_time) / speed_div) % 360 * M_PI / 180.0;
319 rotation[0][0] = cos(angle);
320 rotation[0][2] = sin(angle);
321 rotation[2][0] = -sin(angle);
322 rotation[2][2] = cos(angle);
323
324 glUniformMatrix4fv(window->gl.rotation_uniform, 1, GL_FALSE,
325 (GLfloat *) rotation);
326
327 glClearColor(0.0, 0.0, 0.0, 0.5);
328 glClear(GL_COLOR_BUFFER_BIT);
329
330 glVertexAttribPointer(window->gl.pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
331 glVertexAttribPointer(window->gl.col, 3, GL_FLOAT, GL_FALSE, 0, colors);
332 glEnableVertexAttribArray(window->gl.pos);
333 glEnableVertexAttribArray(window->gl.col);
334
335 glDrawArrays(GL_TRIANGLES, 0, 3);
336
337 glDisableVertexAttribArray(window->gl.pos);
338 glDisableVertexAttribArray(window->gl.col);
339
340 glFlush();
341
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500342 eglSwapBuffers(window->display->egl.dpy, window->egl_surface);
Kristian Høgsberg33418202011-08-16 23:01:28 -0400343 if (callback)
344 wl_callback_destroy(callback);
345
Pekka Paalanen2c2c1062011-12-13 14:50:25 +0200346 window->callback = wl_surface_frame(window->surface);
347 wl_callback_add_listener(window->callback, &frame_listener, window);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100348}
349
Kristian Høgsberg33418202011-08-16 23:01:28 -0400350static const struct wl_callback_listener frame_listener = {
351 redraw
352};
353
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100354static void
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300355input_handle_motion(void *data, struct wl_input_device *input_device,
356 uint32_t time, int32_t sx, int32_t sy)
357{
358}
359
360static void
361input_handle_button(void *data,
362 struct wl_input_device *input_device, uint32_t serial,
363 uint32_t time, uint32_t button, uint32_t state)
364{
365}
366
367static void
368input_handle_axis(void *data,
369 struct wl_input_device *input_device,
370 uint32_t time, uint32_t axis, int32_t value)
371{
372}
373
374static void
375input_handle_key(void *data, struct wl_input_device *input_device,
376 uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
377{
378}
379
380static void
381input_handle_pointer_enter(void *data,
382 struct wl_input_device *input_device,
383 uint32_t serial, struct wl_surface *surface,
384 int32_t sx, int32_t sy)
385{
386 struct display *display = data;
387
388 if (display->window->fullscreen)
389 wl_input_device_attach(input_device, serial, NULL, 0, 0);
390}
391
392static void
393input_handle_pointer_leave(void *data,
394 struct wl_input_device *input_device,
395 uint32_t serial, struct wl_surface *surface)
396{
397}
398
399static void
400input_handle_keyboard_enter(void *data,
401 struct wl_input_device *input_device,
402 uint32_t serial,
403 struct wl_surface *surface,
404 struct wl_array *keys)
405{
406}
407
408static void
409input_handle_keyboard_leave(void *data,
410 struct wl_input_device *input_device,
411 uint32_t serial,
412 struct wl_surface *surface)
413{
414}
415
416static void
417input_handle_touch_down(void *data,
418 struct wl_input_device *wl_input_device,
419 uint32_t serial, uint32_t time,
420 struct wl_surface *surface,
421 int32_t id, int32_t x, int32_t y)
422{
423}
424
425static void
426input_handle_touch_up(void *data,
427 struct wl_input_device *wl_input_device,
428 uint32_t serial, uint32_t time, int32_t id)
429{
430}
431
432static void
433input_handle_touch_motion(void *data,
434 struct wl_input_device *wl_input_device,
435 uint32_t time, int32_t id, int32_t x, int32_t y)
436{
437}
438
439static void
440input_handle_touch_frame(void *data,
441 struct wl_input_device *wl_input_device)
442{
443}
444
445static void
446input_handle_touch_cancel(void *data,
447 struct wl_input_device *wl_input_device)
448{
449}
450
451static const struct wl_input_device_listener input_listener = {
452 input_handle_motion,
453 input_handle_button,
454 input_handle_axis,
455 input_handle_key,
456 input_handle_pointer_enter,
457 input_handle_pointer_leave,
458 input_handle_keyboard_enter,
459 input_handle_keyboard_leave,
460 input_handle_touch_down,
461 input_handle_touch_up,
462 input_handle_touch_motion,
463 input_handle_touch_frame,
464 input_handle_touch_cancel,
465};
466
467static void
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100468display_handle_global(struct wl_display *display, uint32_t id,
469 const char *interface, uint32_t version, void *data)
470{
471 struct display *d = data;
472
Kristian Høgsberg8357cd62011-05-13 13:24:56 -0400473 if (strcmp(interface, "wl_compositor") == 0) {
Kristian Høgsbergf790c792011-08-19 14:41:57 -0400474 d->compositor =
475 wl_display_bind(display, id, &wl_compositor_interface);
Kristian Høgsberg7a5c9792011-06-18 06:12:54 -0400476 } else if (strcmp(interface, "wl_shell") == 0) {
Kristian Høgsbergf790c792011-08-19 14:41:57 -0400477 d->shell = wl_display_bind(display, id, &wl_shell_interface);
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300478 } else if (strcmp(interface, "wl_input_device") == 0) {
479 d->input = wl_display_bind(display, id, &wl_input_device_interface);
480 wl_input_device_add_listener(d->input, &input_listener, d);
Kristian Høgsberg8357cd62011-05-13 13:24:56 -0400481 }
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100482}
483
484static int
485event_mask_update(uint32_t mask, void *data)
486{
487 struct display *d = data;
488
489 d->mask = mask;
490
491 return 0;
492}
493
Pekka Paalanen88e60fc2011-12-13 12:09:09 +0200494static int running = 1;
495
496static void
497signal_int(int signum)
498{
499 running = 0;
500}
501
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100502int
503main(int argc, char **argv)
504{
Pekka Paalanen88e60fc2011-12-13 12:09:09 +0200505 struct sigaction sigint;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100506 struct display display = { 0 };
507 struct window window = { 0 };
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100508
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100509 window.display = &display;
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300510 display.window = &window;
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100511 window.geometry.width = 250;
512 window.geometry.height = 250;
513
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300514 if (argc >= 2 && strcmp("-f", argv[0]))
515 window.fullscreen = 1;
516
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100517 display.display = wl_display_connect(NULL);
518 assert(display.display);
519
520 wl_display_add_global_listener(display.display,
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500521 display_handle_global, &display);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100522
Benjamin Franzke65e50512011-05-31 11:36:31 +0200523 wl_display_get_fd(display.display, event_mask_update, &display);
Kristian Høgsberg33418202011-08-16 23:01:28 -0400524 wl_display_iterate(display.display, WL_DISPLAY_READABLE);
Benjamin Franzke65e50512011-05-31 11:36:31 +0200525
Ander Conselvan de Oliveirad51624f2012-05-02 16:42:23 +0300526 init_egl(&display, window.fullscreen ? 0 : 1);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100527 create_surface(&window);
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500528 init_gl(&window);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100529
Pekka Paalanen88e60fc2011-12-13 12:09:09 +0200530 sigint.sa_handler = signal_int;
531 sigemptyset(&sigint.sa_mask);
532 sigint.sa_flags = SA_RESETHAND;
533 sigaction(SIGINT, &sigint, NULL);
534
Kristian Høgsberg33418202011-08-16 23:01:28 -0400535 redraw(&window, NULL, 0);
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100536
Pekka Paalanen88e60fc2011-12-13 12:09:09 +0200537 while (running)
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100538 wl_display_iterate(display.display, display.mask);
Kristian Høgsberga495a5e2011-02-04 15:31:33 -0500539
Pekka Paalanen88e60fc2011-12-13 12:09:09 +0200540 fprintf(stderr, "simple-egl exiting\n");
541
Pekka Paalanen2c2c1062011-12-13 14:50:25 +0200542 destroy_surface(&window);
543 fini_egl(&display);
544
545 if (display.shell)
546 wl_shell_destroy(display.shell);
547
548 if (display.compositor)
549 wl_compositor_destroy(display.compositor);
550
Pekka Paalanenfb850c42011-12-15 10:07:52 +0200551 wl_display_flush(display.display);
Kristian Høgsbergfcfc83f2012-02-28 14:29:19 -0500552 wl_display_disconnect(display.display);
Pekka Paalanen2c2c1062011-12-13 14:50:25 +0200553
Benjamin Franzkeaabdce02011-01-15 00:40:17 +0100554 return 0;
555}