From 5500ce377a0a552bfa858232f7086c197d0ab458 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 18 Apr 2025 15:14:31 +0200 Subject: Wayland rendering now works --- src/graphics/backend/egl.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/graphics/backend/egl.c') diff --git a/src/graphics/backend/egl.c b/src/graphics/backend/egl.c index f92e2fc..cabbf04 100644 --- a/src/graphics/backend/egl.c +++ b/src/graphics/backend/egl.c @@ -32,7 +32,7 @@ static bool xvisual_match_alpha(Display *dpy, XVisualInfo *visual_info, bool alp return (alpha && pict_format->direct.alphaMask > 0) || (!alpha && pict_format->direct.alphaMask == 0); } -static bool mgl_graphics_context_choose(mgl_graphics_egl *self, mgl_context *context, bool alpha) { +static bool mgl_graphics_egl_choose_config(mgl_graphics_egl *self, mgl_context *context, bool alpha) { self->configs = NULL; self->ecfg = NULL; self->visual_info = NULL; @@ -40,13 +40,13 @@ static bool mgl_graphics_context_choose(mgl_graphics_egl *self, mgl_context *con int32_t num_configs = 0; context->gl.eglGetConfigs(self->display, NULL, 0, &num_configs); if(num_configs == 0) { - fprintf(stderr, "mgl error: no configs found\n"); + fprintf(stderr, "mgl error: mgl_graphics_egl_choose_config: no configs found\n"); return false; } self->configs = (EGLConfig*)calloc(num_configs, sizeof(EGLConfig)); if(!self->configs) { - fprintf(stderr, "mgl error: failed to allocate %d configs\n", (int)num_configs); + fprintf(stderr, "mgl error: mgl_graphics_egl_choose_config: failed to allocate %d configs\n", (int)num_configs); return false; } @@ -54,6 +54,9 @@ static bool mgl_graphics_context_choose(mgl_graphics_egl *self, mgl_context *con for(int i = 0; i < num_configs; i++) { self->ecfg = self->configs[i]; + //if(mgl_graphics_egl_get_config_attrib(self, self->ecfg, EGL_RENDERABLE_TYPE) != EGL_OPENGL_ES2_BIT) + // continue; + if(mgl_graphics_egl_get_config_attrib(self, self->ecfg, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER) continue; @@ -94,14 +97,13 @@ static bool mgl_graphics_context_choose(mgl_graphics_egl *self, mgl_context *con } } - if(context->window_system == MGL_WINDOW_SYSTEM_X11 && !self->visual_info) { - if(self->configs) { - free(self->configs); - self->configs = NULL; - } - self->ecfg = NULL; + if(!self->ecfg) { + fprintf(stderr, "mgl error: mgl_graphics_egl_choose_config: no appropriate glx config found\n"); + return false; + } - fprintf(stderr, "mgl error: mgl_graphics_context_choose: no appropriate visual found\n"); + if(context->window_system == MGL_WINDOW_SYSTEM_X11 && !self->visual_info) { + fprintf(stderr, "mgl error: mgl_graphics_egl_choose_config: no appropriate visual found\n"); return false; } @@ -188,7 +190,7 @@ bool mgl_graphics_egl_init(mgl_graphics *self) { return false; } - if(!mgl_graphics_context_choose(impl, context, self->alpha)) { + if(!mgl_graphics_egl_choose_config(impl, context, self->alpha)) { mgl_graphics_egl_deinit(self); return false; } -- cgit v1.2.3-70-g09d2