diff options
author | Brandon Dowdy <berylline@users.noreply.github.com> | 2021-01-28 23:13:53 +0000 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-01-29 10:03:24 +0100 |
commit | 34e7f69d6942bd37361f27c5894edc9f522d49e1 (patch) | |
tree | e1f722c0114453371711acf471afc2c38e1d2d88 /examples/layer-shell.c | |
parent | 50b9921642af61487e2d0f425695342bf7c4ad78 (diff) |
examples: remove dependency on wlr_egl from clients
The specified clients in this commit used to rely on wlr_egl and
some of its related functions in order to render surfaces.
This is no longer the case as of this commit.
Diffstat (limited to 'examples/layer-shell.c')
-rw-r--r-- | examples/layer-shell.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/examples/layer-shell.c b/examples/layer-shell.c index f4cdaf3b..19f76a68 100644 --- a/examples/layer-shell.c +++ b/examples/layer-shell.c @@ -13,6 +13,7 @@ #include <wayland-egl.h> #include <wlr/render/egl.h> #include <wlr/util/log.h> +#include "egl_common.h" #include "wlr-layer-shell-unstable-v1-client-protocol.h" #include "xdg-shell-client-protocol.h" @@ -29,7 +30,6 @@ struct zwlr_layer_surface_v1 *layer_surface; static struct wl_output *wl_output; struct wl_surface *wl_surface; -struct wlr_egl *egl; struct wl_egl_window *egl_window; struct wlr_egl_surface *egl_surface; struct wl_callback *frame_callback; @@ -94,7 +94,7 @@ static struct wl_callback_listener popup_frame_listener = { }; static void draw(void) { - eglMakeCurrent(egl->display, egl_surface, egl_surface, egl->context); + eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context); struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); @@ -143,7 +143,7 @@ static void draw(void) { frame_callback = wl_surface_frame(wl_surface); wl_callback_add_listener(frame_callback, &frame_listener, NULL); - eglSwapBuffers(egl->display, egl_surface); + eglSwapBuffers(egl_display, egl_surface); demo.last_frame = ts; } @@ -151,7 +151,7 @@ static void draw(void) { static void draw_popup(void) { static float alpha_mod = -0.01; - eglMakeCurrent(egl->display, popup_egl_surface, popup_egl_surface, egl->context); + eglMakeCurrent(egl_display, popup_egl_surface, popup_egl_surface, egl_context); glViewport(0, 0, popup_width, popup_height); glClearColor(popup_red, 0.5f, 0.5f, popup_alpha); popup_alpha += alpha_mod; @@ -163,7 +163,7 @@ static void draw_popup(void) { popup_frame_callback = wl_surface_frame(popup_wl_surface); assert(popup_frame_callback); wl_callback_add_listener(popup_frame_callback, &popup_frame_listener, NULL); - eglSwapBuffers(egl->display, popup_egl_surface); + eglSwapBuffers(egl_display, popup_egl_surface); wl_surface_commit(popup_wl_surface); } @@ -188,7 +188,7 @@ static void xdg_popup_configure(void *data, struct xdg_popup *xdg_popup, } static void popup_destroy(void) { - wlr_egl_destroy_surface(egl, popup_egl_surface); + eglDestroySurface(egl_display, popup_egl_surface); wl_egl_window_destroy(popup_egl_window); xdg_popup_destroy(popup); wl_surface_destroy(popup_wl_surface); @@ -242,8 +242,9 @@ static void create_popup(uint32_t serial) { popup_wl_surface = surface; popup_egl_window = wl_egl_window_create(surface, popup_width, popup_height); assert(popup_egl_window); - popup_egl_surface = wlr_egl_create_surface(egl, popup_egl_window); - assert(popup_egl_surface); + popup_egl_surface = eglCreatePlatformWindowSurfaceEXT( + egl_display, egl_config, popup_egl_window, NULL); + assert(popup_egl_surface != EGL_NO_SURFACE); draw_popup(); } @@ -260,7 +261,7 @@ static void layer_surface_configure(void *data, static void layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *surface) { - wlr_egl_destroy_surface(egl, egl_surface); + eglDestroySurface(egl_display, egl_surface); wl_egl_window_destroy(egl_window); zwlr_layer_surface_v1_destroy(surface); wl_surface_destroy(wl_surface); @@ -631,8 +632,7 @@ int main(int argc, char **argv) { cursor_surface = wl_compositor_create_surface(compositor); assert(cursor_surface); - EGLint attribs[] = { EGL_ALPHA_SIZE, 8, EGL_NONE }; - egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs); + egl_init(display); wl_surface = wl_compositor_create_surface(compositor); assert(wl_surface); @@ -654,8 +654,9 @@ int main(int argc, char **argv) { egl_window = wl_egl_window_create(wl_surface, width, height); assert(egl_window); - egl_surface = wlr_egl_create_surface(egl, egl_window); - assert(egl_surface); + egl_surface = eglCreatePlatformWindowSurfaceEXT( + egl_display, egl_config, egl_window, NULL); + assert(egl_surface != EGL_NO_SURFACE); wl_display_roundtrip(display); draw(); |