From 3bf156c9d9598acbee38c49d17cdb7d77e79d520 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Thu, 28 Oct 2021 13:07:25 +0100 Subject: Add basic HiDPI scaling and a subsurface. --- src/egl.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/egl.c') diff --git a/src/egl.c b/src/egl.c index 363ecb8..2e6b7a7 100644 --- a/src/egl.c +++ b/src/egl.c @@ -1,28 +1,26 @@ #include #include #include -#include "client.h" +#include "egl.h" #include "log.h" -static void egl_log_error(); static const char *egl_error_string(); -void egl_create_window(struct client_state *state) +void egl_create_window(struct egl *egl, struct wl_surface *wl_surface, uint32_t width, uint32_t height) { - state->egl.window = wl_egl_window_create( - state->wl_surface, - state->width, - state->height); + egl->window = wl_egl_window_create( + wl_surface, + width, + height); - if (state->egl.window == EGL_NO_SURFACE) { + if (egl->window == EGL_NO_SURFACE) { egl_log_error("Couldn't create EGL window"); } } -void egl_create_context(struct client_state *state) +void egl_create_context(struct egl *egl, struct wl_display *wl_display) { - struct egl *egl = &state->egl; - egl->display = eglGetDisplay(state->wl_display); + egl->display = eglGetDisplay(wl_display); if (egl->display == EGL_NO_DISPLAY) { egl_log_error("Couldn't get EGL display"); return; @@ -85,6 +83,18 @@ void egl_log_error(const char *msg) { log_error("%s: %s\n", msg, egl_error_string()); } +void egl_make_current(struct egl *egl) { + bool result = eglMakeCurrent(egl->display, egl->surface, egl->surface, egl->context); + if (!result) { + egl_log_error("Couldn't make EGL context current"); + return; + } +} + +void egl_swap_buffers(struct egl *egl) { + eglSwapBuffers(egl->display, egl->surface); +} + const char *egl_error_string() { switch(eglGetError()) { case EGL_SUCCESS: -- cgit v1.2.3