summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build1
-rw-r--r--src/window.h8
-rw-r--r--src/window_glfw.c15
-rw-r--r--src/window_wayland.c2
4 files changed, 20 insertions, 6 deletions
diff --git a/meson.build b/meson.build
index fcef359..ba23533 100644
--- a/meson.build
+++ b/meson.build
@@ -67,6 +67,7 @@ elif get_option('api') == 'opengl'
egl = dependency('egl')
stela_deps += [egl]
stela_src += ['src/egl_common.c']
+ stela_args += ['-DSTELA_USE_EGL']
endif
if use_glad
stela_deps += [subproject('glad', default_options: [
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,