summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-01-23 10:22:44 -0500
committerAndrew Opalach <andrew@akon.city> 2025-01-23 10:22:44 -0500
commita55bfe4c21858eef0eb1bddf4085fcfde1b7e07d (patch)
tree8e33c782b5e72906aef9a68441cedcbab4308181
parent35a0c4feb6569895bf19c05c510a674666dcc4c6 (diff)
downloadstela-a55bfe4c21858eef0eb1bddf4085fcfde1b7e07d.tar.gz
stela-a55bfe4c21858eef0eb1bddf4085fcfde1b7e07d.tar.bz2
stela-a55bfe4c21858eef0eb1bddf4085fcfde1b7e07d.zip
Hook up EGL where we can, build update
Signed-off-by: Andrew Opalach <andrew@akon.city>
-rw-r--r--.gitignore9
-rw-r--r--meson.build5
-rw-r--r--src/window.h5
-rw-r--r--src/window_glfm.c4
-rw-r--r--src/window_glfw.c34
-rw-r--r--src/window_glfw.h6
-rw-r--r--src/window_wayland.c7
-rw-r--r--src/window_wayland.h1
-rw-r--r--src/window_x11.c3
-rw-r--r--src/window_x11.h1
-rw-r--r--subprojects/glfm.wrap3
-rw-r--r--subprojects/glfw3.wrap1
-rw-r--r--subprojects/libalabaster.wrap2
-rw-r--r--subprojects/libnaunet.wrap2
-rw-r--r--subprojects/packagefiles/glfm/get_egl_internal.diff39
-rw-r--r--subprojects/packagefiles/vulkan-headers/meson.build (renamed from subprojects/packagefiles/vulkan/meson.build)0
-rw-r--r--subprojects/vulkan.wrap5
-rw-r--r--subprojects/wayland-protocols.wrap1
-rw-r--r--subprojects/wlr-protocols.wrap1
19 files changed, 105 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index 38fa51e..6b7e3ff 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,16 @@
.cache/
build*/
compile_commands.json
+subprojects/c89atomic-*/
subprojects/c89atomic.wrap
subprojects/glad/
-subprojects/glfm/
+subprojects/glfm-*/
+subprojects/glfw-*/
subprojects/libalabaster
subprojects/libalabaster/
+subprojects/libev-*/
subprojects/libev.wrap
subprojects/libnaunet
subprojects/libnaunet/
-subprojects/wayland-protocols/
-subprojects/wlr-protocols/
+subprojects/wayland-protocols-*/
+subprojects/wlr-protocols-*/
diff --git a/meson.build b/meson.build
index ba23533..8d8ff85 100644
--- a/meson.build
+++ b/meson.build
@@ -181,6 +181,9 @@ elif get_option('window') == 'glfw'
stela_src += ['src/window_glfw.c']
stela_deps += [glfw3]
stela_args += ['-DSTELA_WINDOW_GLFW']
+ if is_linux
+ stela_args += ['-DSTELA_USE_EGL']
+ endif
elif get_option('window') == 'glfm'
glfm = dependency('glfm', required: false, allow_fallback: false)
if not glfm.found()
@@ -192,7 +195,7 @@ elif get_option('window') == 'glfm'
endif
stela_src += ['src/window_glfm.c']
stela_deps += [glfm]
- stela_args += ['-DSTELA_WINDOW_GLFM']
+ stela_args += ['-DSTELA_WINDOW_GLFM', '-DSTELA_USE_EGL']
endif
stela = declare_dependency(include_directories: stela_inc,
diff --git a/src/window.h b/src/window.h
index 37146ea..afe797e 100644
--- a/src/window.h
+++ b/src/window.h
@@ -15,7 +15,6 @@
#endif
#include <al/types.h>
-#include <al/array.h>
#include <al/lib.h>
#include <al/ring_buffer.h>
@@ -86,8 +85,8 @@ struct stl_window {
const char *const *(*vk_get_extensions)(u32 *);
#elif defined STELA_API_OPENGL
#ifdef STELA_USE_EGL
- EGLDisplay display;
- EGLContext context;
+ EGLDisplay egl_display;
+ EGLContext egl_context;
#endif
void (*(*get_gl_proc_address)(const char *))(void);
bool (*gl_loader_load)(void *);
diff --git a/src/window_glfm.c b/src/window_glfm.c
index 74310f7..4e4f034 100644
--- a/src/window_glfm.c
+++ b/src/window_glfm.c
@@ -37,6 +37,10 @@ static bool window_glfm_create_window(struct stl_window *window, s32 width, s32
glfmGetDisplaySize(glfm->display, &width, &height);
glfm->w.width = width;
glfm->w.height = height;
+#ifdef STELA_USE_EGL
+ glfm->w.egl_display = (EGLDisplay)glfmGetEglDisplay(glfm->display);
+ glfm->w.egl_context = (EGLContext)glfmGetEglContext(glfm->display);
+#endif
return true;
}
diff --git a/src/window_glfw.c b/src/window_glfw.c
index c85c14c..dbf6a70 100644
--- a/src/window_glfw.c
+++ b/src/window_glfw.c
@@ -172,6 +172,10 @@ static bool window_glfw_create_window(struct stl_window *window, s32 width, s32
}
#ifdef STELA_API_OPENGL
+#ifdef STELA_USE_EGL
+ glfw->w.egl_display = glfwGetEGLDisplay();
+ glfw->w.egl_context = glfwGetEGLContext(glfw->window);
+#endif
glfwMakeContextCurrent(glfw->window);
glfwSwapInterval((flags & STELA_WINDOW_VSYNC) ? 1 : 0);
glfwMakeContextCurrent(NULL);
@@ -182,6 +186,11 @@ static bool window_glfw_create_window(struct stl_window *window, s32 width, s32
glfwGetFramebufferSize(glfw->window, &glfw->w.width, &glfw->w.height);
glfwSetWindowSizeLimits(glfw->window, STELA_MIN_WIDTH, STELA_MIN_HEIGHT, GLFW_DONT_CARE, GLFW_DONT_CARE);
+ glfw->prev.x = 0;
+ glfw->prev.y = 0;
+ glfw->prev.width = 0;
+ glfw->prev.height = 0;
+
glfwSetWindowUserPointer(glfw->window, glfw);
glfwSetKeyCallback(glfw->window, key_callback);
@@ -213,17 +222,21 @@ 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)
+static GLFWmonitor *get_current_monitor(GLFWwindow *window, s32 wx, s32 wy)
{
+ if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND) {
+ // Calculating the current monitor doesn't work on Wayland
+ // because we can't know the position of the window.
+ return glfwGetPrimaryMonitor();
+ }
+
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);
const GLFWvidmode *mode;
@@ -257,13 +270,18 @@ static void window_glfw_toggle_fullscreen(struct stl_window *window)
{
struct stl_window_glfw *glfw = (struct stl_window_glfw *)window;
if (!glfw->w.fullscreen) {
- glfwGetWindowPos(glfw->window, &glfw->prev.x, &glfw->prev.y);
- glfw->prev.width = glfw->w.width;
- glfw->prev.height = glfw->w.height;
- GLFWmonitor *monitor = get_current_monitor(glfw->window);
+ if (glfwGetPlatform() != GLFW_PLATFORM_WAYLAND) {
+ glfwGetWindowPos(glfw->window, &glfw->prev.x, &glfw->prev.y);
+ }
+ GLFWmonitor *monitor = get_current_monitor(glfw->window, glfw->prev.x, glfw->prev.y);
if (!monitor) return;
const GLFWvidmode *mode = glfwGetVideoMode(monitor);
- glfwSetWindowMonitor(glfw->window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
+ f32 xscale, yscale;
+ glfwGetMonitorContentScale(monitor, &xscale, &yscale);
+ glfw->prev.width = glfw->w.width / xscale;
+ glfw->prev.height = glfw->w.height / yscale;
+ glfwSetWindowMonitor(glfw->window, monitor, 0, 0,
+ mode->width / xscale, mode->height / yscale, mode->refreshRate);
//glfwSetInputMode(glfw->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
} else {
glfwSetWindowMonitor(glfw->window, NULL, glfw->prev.x, glfw->prev.y,
diff --git a/src/window_glfw.h b/src/window_glfw.h
index 67cf63a..f834f29 100644
--- a/src/window_glfw.h
+++ b/src/window_glfw.h
@@ -2,10 +2,14 @@
#ifdef STELA_API_VULKAN
#define GLFW_INCLUDE_VULKAN
+#else
+#define GLFW_INCLUDE_NONE
#endif
#include <GLFW/glfw3.h>
-#ifndef _WIN32
+#ifdef STELA_USE_EGL
#define GLFW_EXPOSE_NATIVE_EGL
+#define GLFW_NATIVE_INCLUDE_NONE
+#include "egl_common.h"
#include <GLFW/glfw3native.h>
#endif
diff --git a/src/window_wayland.c b/src/window_wayland.c
index d37d5d6..40886c2 100644
--- a/src/window_wayland.c
+++ b/src/window_wayland.c
@@ -215,6 +215,7 @@ static void pointer_enter(void *data, struct wl_pointer *pointer,
struct stl_window_wayland *wl = (struct stl_window_wayland *)data;
(void)pointer;
global.active_surface = surface;
+ //wl_pointer_set_cursor(wl->pointer, serial, NULL, 0, 0);
if (wl->cursor_shape_device) {
wp_cursor_shape_device_v1_set_shape(wl->cursor_shape_device, serial, WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT);
}
@@ -681,8 +682,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;
+ wl->w.egl_display = wl->egl.display;
+ wl->w.egl_context = wl->egl.context;
const EGLint surface_attr[] = {
EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
@@ -703,7 +704,7 @@ static bool create_context_internal(struct stl_window_wayland *wl)
wl->fds[0].fd = global.display_fd;
wl->fds[0].events = POLLIN;
#if defined STELA_POLL_INLINE && defined STELA_PAUSE
- wl->fds[1].fd = eventfd(0, 0);
+ wl->fds[1].fd = nn_eventfd(0, 0);
wl->fds[1].events = POLLIN;
#endif
wl->registry = wl_display_get_registry(wl->display);
diff --git a/src/window_wayland.h b/src/window_wayland.h
index 9895463..05208d8 100644
--- a/src/window_wayland.h
+++ b/src/window_wayland.h
@@ -1,6 +1,7 @@
#pragma once
#include <al/lib.h>
+#include <al/array.h>
#include <nnwt/socket.h>
#include <wayland-client-core.h>
diff --git a/src/window_x11.c b/src/window_x11.c
index a0e9c69..b02d639 100644
--- a/src/window_x11.c
+++ b/src/window_x11.c
@@ -1,4 +1,5 @@
#include <al/log.h>
+#include <sys/eventfd.h>
#include "window_x11.h"
#include "common.h"
@@ -177,7 +178,7 @@ static bool window_x11_create_window(struct stl_window *window, s32 width, s32 h
xw->fds[0].events = POLLIN;
#if defined STELA_POLL_INLINE && defined STELA_PAUSE
- xw->fds[1].fd = eventfd(0, 0);
+ xw->fds[1].fd = nn_eventfd(0, 0);
xw->fds[1].events = POLLIN;
#endif
diff --git a/src/window_x11.h b/src/window_x11.h
index d198115..f8305dd 100644
--- a/src/window_x11.h
+++ b/src/window_x11.h
@@ -1,5 +1,6 @@
#pragma once
+#include <al/array.h>
#include <nnwt/socket.h>
#include <X11/Xlib.h>
diff --git a/subprojects/glfm.wrap b/subprojects/glfm.wrap
index fdb6598..ae8e1ab 100644
--- a/subprojects/glfm.wrap
+++ b/subprojects/glfm.wrap
@@ -1,5 +1,8 @@
[wrap-git]
+directory = glfm-38cc2c1
url = https://github.com/brackeen/glfm.git
revision = 38cc2c12ac1b0d59a269e72cc2d965f3f896ef52
depth = 1
+patch_directory = glfm
+diff_files = glfm/get_egl_internal.diff
method = cmake
diff --git a/subprojects/glfw3.wrap b/subprojects/glfw3.wrap
index 9754a3f..625b4a3 100644
--- a/subprojects/glfw3.wrap
+++ b/subprojects/glfw3.wrap
@@ -1,4 +1,5 @@
[wrap-git]
+directory = glfw3-e7ea71b
url = https://github.com/glfw/glfw.git
revision = e7ea71be039836da3a98cea55ae5569cb5eb885c
depth = 1
diff --git a/subprojects/libalabaster.wrap b/subprojects/libalabaster.wrap
index 1fec842..cceb244 100644
--- a/subprojects/libalabaster.wrap
+++ b/subprojects/libalabaster.wrap
@@ -1,4 +1,4 @@
[wrap-git]
url = https://git.akon.city/libalabaster
-revision = 209310c561d89c9ed2040aa7053b320d32cc393c
+revision = 562c730ac38749fb43ae5b7b53ae5f3043166bd1
depth = 1
diff --git a/subprojects/libnaunet.wrap b/subprojects/libnaunet.wrap
index 0466a46..7cce0e2 100644
--- a/subprojects/libnaunet.wrap
+++ b/subprojects/libnaunet.wrap
@@ -1,4 +1,4 @@
[wrap-git]
url = https://git.akon.city/libnaunet
-revision = cef6cabce7ae97e9edfb6821ce4393d714579866
+revision = e48874a91a86ef561aa4b3298d6170ec9777954e
depth = 1
diff --git a/subprojects/packagefiles/glfm/get_egl_internal.diff b/subprojects/packagefiles/glfm/get_egl_internal.diff
new file mode 100644
index 0000000..3c9098c
--- /dev/null
+++ b/subprojects/packagefiles/glfm/get_egl_internal.diff
@@ -0,0 +1,39 @@
+diff --git a/include/glfm.h b/include/glfm.h
+index ceace39..d18711c 100644
+--- a/include/glfm.h
++++ b/include/glfm.h
+@@ -892,6 +892,9 @@ ANativeActivity *glfmAndroidGetActivity(void) GLFM_DEPRECATED("Use glfmGetAndroi
+ /// ``GLFMAppFocusFunc``.
+ void *glfmGetAndroidActivity(const GLFMDisplay *display);
+
++void *glfmGetEglDisplay(const GLFMDisplay *display);
++void *glfmGetEglContext(const GLFMDisplay *display);
++
+ #endif // GLFM_EXPOSE_NATIVE_ANDROID
+
+ #ifdef __cplusplus
+diff --git a/src/glfm_android.c b/src/glfm_android.c
+index 67d1927..7942ddf 100644
+--- a/src/glfm_android.c
++++ b/src/glfm_android.c
+@@ -2800,4 +2800,20 @@ void *glfmGetAndroidActivity(const GLFMDisplay *display) {
+ return platformData->activity;
+ }
+
++void *glfmGetEglDisplay(const GLFMDisplay *display) {
++ if (!display || !display->platformData) {
++ return NULL;
++ }
++ GLFMPlatformData *platformData = display->platformData;
++ return platformData->eglDisplay;
++}
++
++void *glfmGetEglContext(const GLFMDisplay *display) {
++ if (!display || !display->platformData) {
++ return NULL;
++ }
++ GLFMPlatformData *platformData = display->platformData;
++ return platformData->eglContext;
++}
++
+ #endif // __ANDROID__
diff --git a/subprojects/packagefiles/vulkan/meson.build b/subprojects/packagefiles/vulkan-headers/meson.build
index f83e5e8..f83e5e8 100644
--- a/subprojects/packagefiles/vulkan/meson.build
+++ b/subprojects/packagefiles/vulkan-headers/meson.build
diff --git a/subprojects/vulkan.wrap b/subprojects/vulkan.wrap
index 838dbb8..03f157a 100644
--- a/subprojects/vulkan.wrap
+++ b/subprojects/vulkan.wrap
@@ -1,8 +1,9 @@
[wrap-git]
+directory = vulkan-headers-1.4.305
url = https://github.com/KhronosGroup/Vulkan-Headers.git
-revision = v1.4.304
+revision = v1.4.305
depth = 1
-patch_directory = vulkan
+patch_directory = vulkan-headers
[provide]
dependency_names = vulkan
diff --git a/subprojects/wayland-protocols.wrap b/subprojects/wayland-protocols.wrap
index 7bab008..c4df786 100644
--- a/subprojects/wayland-protocols.wrap
+++ b/subprojects/wayland-protocols.wrap
@@ -1,4 +1,5 @@
[wrap-git]
+directory = wayland-protocols-1.39
url = https://gitlab.freedesktop.org/wayland/wayland-protocols.git
revision = 1.39
depth = 1
diff --git a/subprojects/wlr-protocols.wrap b/subprojects/wlr-protocols.wrap
index 46541be..4dcf5ad 100644
--- a/subprojects/wlr-protocols.wrap
+++ b/subprojects/wlr-protocols.wrap
@@ -1,4 +1,5 @@
[wrap-git]
+directory = wlr-protocols-ffb89ac
url = https://gitlab.freedesktop.org/wlroots/wlr-protocols.git
revision = ffb89ac790096f6e6272822c8d5df7d0cc6fcdfa
depth = 1