diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/window.h | 8 | ||||
| -rw-r--r-- | src/window_glfw.c | 15 | ||||
| -rw-r--r-- | src/window_wayland.c | 2 |
3 files changed, 19 insertions, 6 deletions
diff --git a/src/window.h b/src/window.h index 3a83843..37146ea 100644 --- a/src/window.h +++ b/src/window.h @@ -19,8 +19,10 @@ #include <al/lib.h> #include <al/ring_buffer.h> -#ifdef STELA_API_VULKAN +#if defined STELA_API_VULKAN #include <vulkan/vulkan.h> +#elif defined STELA_API_OPENGL && defined STELA_USE_EGL +#include "egl_common.h" #endif #ifndef STELA_MIN_WIDTH @@ -83,6 +85,10 @@ struct stl_window { VkResult (*vk_create_surface)(void *, VkInstance, VkSurfaceKHR *); const char *const *(*vk_get_extensions)(u32 *); #elif defined STELA_API_OPENGL +#ifdef STELA_USE_EGL + EGLDisplay display; + EGLContext context; +#endif void (*(*get_gl_proc_address)(const char *))(void); bool (*gl_loader_load)(void *); bool (*gl_make_current)(void *); diff --git a/src/window_glfw.c b/src/window_glfw.c index 01b8961..c85c14c 100644 --- a/src/window_glfw.c +++ b/src/window_glfw.c @@ -129,6 +129,9 @@ static bool window_glfw_create_window(struct stl_window *window, s32 width, s32 struct stl_window_glfw *glfw = (struct stl_window_glfw *)window; (void)monitor; + glfwWindowHintString(GLFW_WAYLAND_APP_ID, name); + glfwWindowHintString(GLFW_X11_CLASS_NAME, name); + #if defined STELA_API_VULKAN || defined STELA_API_DX11 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); #elif defined STELA_API_OPENGL @@ -212,22 +215,23 @@ static void window_glfw_resize(struct stl_window *window, s32 width, s32 height) // https://stackoverflow.com/a/31526753 static GLFWmonitor *get_current_monitor(GLFWwindow *window) { - s32 best_overlap = 0; - GLFWmonitor *best_monitor = NULL; + s32 monitor_count; + GLFWmonitor **monitors = glfwGetMonitors(&monitor_count); + if (monitor_count == 0) return NULL; + + GLFWmonitor *best_monitor = monitors[0]; s32 wx, wy; s32 ww, wh; glfwGetWindowPos(window, &wx, &wy); glfwGetWindowSize(window, &ww, &wh); - s32 monitor_count; - GLFWmonitor **monitors = glfwGetMonitors(&monitor_count); - const GLFWvidmode *mode; s32 mx, my; s32 mw, mh; s32 overlap; + s32 best_overlap = 0; for (s32 i = 0; i < monitor_count; i++) { mode = glfwGetVideoMode(monitors[i]); @@ -257,6 +261,7 @@ static void window_glfw_toggle_fullscreen(struct stl_window *window) glfw->prev.width = glfw->w.width; glfw->prev.height = glfw->w.height; GLFWmonitor *monitor = get_current_monitor(glfw->window); + if (!monitor) return; const GLFWvidmode *mode = glfwGetVideoMode(monitor); glfwSetWindowMonitor(glfw->window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); //glfwSetInputMode(glfw->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); diff --git a/src/window_wayland.c b/src/window_wayland.c index c92549c..c3de3e1 100644 --- a/src/window_wayland.c +++ b/src/window_wayland.c @@ -678,6 +678,8 @@ static bool wl_egl_init(struct stl_window_wayland *wl) } wl->w.get_gl_proc_address = eglGetProcAddress; + wl->w.display = wl->egl.display; + wl->w.context = wl->egl.context; const EGLint surface_attr[] = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER, |