From e541b7969ace57dbb448ae6adff02bd0a726ade4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Tue, 21 Jun 2022 19:52:39 +0200 Subject: [PATCH] Wayland: Only create EGL window if using EGL (cherry picked from commit d578c2ddfeb6a31c532ddc29de289762745548d2) --- src/wl_window.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/wl_window.c b/src/wl_window.c index fd625dbe..907ce70a 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -351,7 +351,9 @@ static void resizeWindow(_GLFWwindow* window) int scale = window->wl.scale; int scaledWidth = window->wl.width * scale; int scaledHeight = window->wl.height * scale; - wl_egl_window_resize(window->wl.egl.window, scaledWidth, scaledHeight, 0, 0); + + if (window->wl.egl.window) + wl_egl_window_resize(window->wl.egl.window, scaledWidth, scaledHeight, 0, 0); if (!window->wl.transparent) setContentAreaOpaque(window); _glfwInputFramebufferSize(window, scaledWidth, scaledHeight); @@ -772,15 +774,6 @@ static GLFWbool createNativeSurface(_GLFWwindow* window, wl_surface_set_user_data(window->wl.surface, window); - window->wl.egl.window = wl_egl_window_create(window->wl.surface, - wndconfig->width, - wndconfig->height); - if (!window->wl.egl.window) - { - _glfwInputError(GLFW_PLATFORM_ERROR, "Wayland: Failed to create EGL window"); - return GLFW_FALSE; - } - window->wl.width = wndconfig->width; window->wl.height = wndconfig->height; window->wl.scale = 1; @@ -1880,6 +1873,16 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (ctxconfig->source == GLFW_EGL_CONTEXT_API || ctxconfig->source == GLFW_NATIVE_CONTEXT_API) { + window->wl.egl.window = wl_egl_window_create(window->wl.surface, + wndconfig->width, + wndconfig->height); + if (!window->wl.egl.window) + { + _glfwInputError(GLFW_PLATFORM_ERROR, + "Wayland: Failed to create EGL window"); + return GLFW_FALSE; + } + if (!_glfwInitEGL()) return GLFW_FALSE; if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))