summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build23
-rw-r--r--meson_options.txt1
-rw-r--r--src/egl_common.c4
-rw-r--r--src/window.c11
-rw-r--r--src/window.h1
-rw-r--r--src/window_glfm.c8
-rw-r--r--src/window_glfw.c8
-rw-r--r--src/window_kms.c155
-rw-r--r--src/window_kms.h10
-rw-r--r--src/window_wayland.c8
-rw-r--r--src/window_x11.c8
11 files changed, 199 insertions, 38 deletions
diff --git a/meson.build b/meson.build
index ec32412..995f35c 100644
--- a/meson.build
+++ b/meson.build
@@ -54,6 +54,20 @@ elif get_option('api') == 'opengl'
use_glad = false
use_gles = false
if get_option('window') not in ['glfm']
+ if get_option('window') in ['x11', 'wayland']
+ if get_option('egl-brcm')
+ # Raspberry Pi (legacy proprietary driver)
+ #brcmEGL = dependency('brcmegl')
+ #brcmGLESv2 = dependency('brcmglesv2')
+ #stela_deps += [brcmEGL, brcmGLESv2]
+ use_gles = true
+ # Try to use Mesa VC4 instead.
+ else
+ endif
+ egl = dependency('egl')
+ stela_deps += [egl]
+ stela_src += ['src/egl_common.c']
+ endif
if use_glad
stela_deps += [subproject('glad', default_options: [
use_gles ? 'use_gles=true' : 'use_gles=false'
@@ -62,15 +76,6 @@ elif get_option('api') == 'opengl'
else
stela_deps += [dependency('gl')]
endif
- if get_option('window') in ['x11', 'wayland']
- egl = dependency('egl')
- stela_src += ['src/egl_common.c']
- stela_deps += [egl]
- # Raspberry Pi
- #brcmEGL = compiler.find_library('brcmEGL')
- #brcmGLESv2 = compiler.find_library('brcmGLESv2')
- #stela_deps += [brcmEGL, brcmGLESv2]
- endif
endif
if use_gles
stela_args += ['-DSTELA_USE_GLES']
diff --git a/meson_options.txt b/meson_options.txt
index 17e6c3b..9612976 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,6 @@
option('api', type: 'combo', choices: ['null', 'opengl', 'vulkan', 'dx11'], value: 'null')
option('window', type: 'combo', choices: ['wayland', 'x11', 'glfw', 'glfm'], value: 'wayland')
+option('egl-brcm', type: 'boolean', value: false)
option('poll', type: 'combo', choices: ['inline', 'fd'], value: 'inline')
option('event-buffer', type: 'boolean', value: false)
option('pause', type: 'boolean', value: true)
diff --git a/src/egl_common.c b/src/egl_common.c
index 7952894..b0a38f2 100644
--- a/src/egl_common.c
+++ b/src/egl_common.c
@@ -43,8 +43,10 @@ bool stl_load_egl(struct stl_egl_global *global)
al_log_error("egl", "Failed to load EGL (glad).");
return false;
}
-#endif
al_log_info("egl", "Using EGL (glad) version %s.", eglQueryString(global->display, EGL_VERSION));
+#else
+ al_log_info("egl", "Using EGL version %s.", eglQueryString(global->display, EGL_VERSION));
+#endif
return true;
}
diff --git a/src/window.c b/src/window.c
index c1ac53e..7dde823 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2,6 +2,17 @@
#include "window.h"
+void stl_window_common_init(struct stl_window *window)
+{
+#ifdef STELA_EVENT_BUFFER
+ window->data = al_malloc(STELA_EVENTS_SIZE);
+ al_ring_buffer_init(&window->events, window->data, STELA_EVENTS_SIZE);
+#endif
+#ifdef STELA_PAUSE
+ window->pending_refresh = true;
+#endif
+}
+
#define GET_EVENT_CHUNK(op) \
size_t size; \
u8 *ptr = al_ring_buffer_write_chunk(&window->events, &size); \
diff --git a/src/window.h b/src/window.h
index a68a75f..3a83843 100644
--- a/src/window.h
+++ b/src/window.h
@@ -136,6 +136,7 @@ s32 stl_global_get_poll_fd();
void stl_global_process_events();
void stl_global_close(void);
+void stl_window_common_init(struct stl_window *window);
struct stl_window *stl_window_create(void *context);
void stl_window_send_pointer_pos_event(struct stl_window *window, f64 x, f64 y);
void stl_window_send_scroll_event(struct stl_window *window, f64 y);
diff --git a/src/window_glfm.c b/src/window_glfm.c
index b9639dc..646b978 100644
--- a/src/window_glfm.c
+++ b/src/window_glfm.c
@@ -124,13 +124,7 @@ struct stl_window *stl_window_create(void *context)
al_log_info("stela", "Wrapping GLFM window.");
struct stl_window_glfm *glfm = al_alloc_object(struct stl_window_glfm);
glfm->display = (GLFMDisplay *)context;
-#ifdef STELA_EVENT_BUFFER
- glfm->w.data = al_malloc(STELA_EVENTS_SIZE);
- al_ring_buffer_init(&glfm->w.events, glfm->w.data, STELA_EVENTS_SIZE);
-#endif
-#ifdef STELA_PAUSE
- glfm->w.pending_refresh = true;
-#endif
+ stl_window_common_init(&glfm->w);
glfm->w.fullscreen = false;
glfm->w.create_context = NULL;
glfm->w.create_window = window_glfm_create_window;
diff --git a/src/window_glfw.c b/src/window_glfw.c
index 24389a0..ee85f81 100644
--- a/src/window_glfw.c
+++ b/src/window_glfw.c
@@ -361,13 +361,7 @@ struct stl_window *stl_window_create(void *context)
(void)context;
al_log_info("stela", "Creating GLFW3 window.");
struct stl_window_glfw *glfw = al_alloc_object(struct stl_window_glfw);
-#ifdef STELA_EVENT_BUFFER
- glfw->w.data = al_malloc(STELA_EVENTS_SIZE);
- al_ring_buffer_init(&glfw->w.events, glfw->w.data, STELA_EVENTS_SIZE);
-#endif
-#ifdef STELA_PAUSE
- glfw->w.pending_refresh = true;
-#endif
+ stl_window_common_init(&glfw->w);
glfw->w.fullscreen = false;
glfw->w.create_context = NULL;
glfw->w.create_window = window_glfw_create_window;
diff --git a/src/window_kms.c b/src/window_kms.c
new file mode 100644
index 0000000..5fd24ce
--- /dev/null
+++ b/src/window_kms.c
@@ -0,0 +1,155 @@
+#include <al/log.h>
+
+#include "window_kms.h"
+
+void stl_set_output_discovered_callback(void (*output_discovered)(void *, struct stl_monitor *), void *userdata)
+{
+ (void)output_discovered;
+ (void)userdata;
+}
+
+bool stl_global_init(bool skip_graphics)
+{
+ (void)skip_graphics;
+ return false;
+}
+
+s32 stl_global_get_poll_fd()
+{
+ return -1;
+}
+
+void stl_global_process_events()
+{
+}
+
+void stl_global_close(void)
+{
+}
+
+static bool window_kms_create_window(struct stl_window *window, s32 width, s32 height,
+ const char *monitor, const char *name, s32 flags)
+{
+ struct stl_window_kms *kms = (struct stl_window_kms *)window;
+ (void)kms;
+ (void)monitor;
+ (void)name;
+ (void)flags;
+ (void)width;
+ (void)height;
+ return true;
+}
+
+static void window_kms_resize_internal(struct stl_window *window, s32 width, s32 height)
+{
+ (void)window;
+ (void)width;
+ (void)height;
+}
+
+static void window_kms_resize(struct stl_window *window, s32 width, s32 height)
+{
+ (void)window;
+ (void)width;
+ (void)height;
+}
+
+static void window_kms_toggle_fullscreen(struct stl_window *window)
+{
+ (void)window;
+}
+
+#ifdef STELA_POLL_INLINE
+static bool window_kms_poll(struct stl_window *window, bool block)
+{
+ (void)window;
+ (void)block;
+ return true;
+}
+
+#ifdef STELA_PAUSE
+static void window_kms_wake(struct stl_window *window)
+{
+ (void)window;
+}
+#endif
+#endif
+
+static void window_kms_process_events(struct stl_window *window)
+{
+ (void)window;
+}
+
+#ifdef STELA_PAUSE
+static bool window_kms_should_refresh(struct stl_window *window)
+{
+ (void)window;
+ return true;
+}
+#endif
+
+static void window_kms_free(struct stl_window **window)
+{
+ (void)window;
+}
+
+#if defined STELA_API_VULKAN
+#elif defined STELA_API_OPENGL
+static bool window_kms_gl_loader_load(void *data)
+{
+ (void)data;
+ return true;
+}
+
+static bool window_kms_gl_make_current(void *data)
+{
+ (void)data;
+ return true;
+}
+
+static void window_kms_gl_release_current(void *data)
+{
+ (void)data;
+}
+
+static void window_kms_gl_swap_buffers(void *data)
+{
+ struct stl_window_kms *kms = (struct stl_window_kms *)data;
+ (void)kms;
+}
+#endif
+
+struct stl_window *stl_window_create(void *context)
+{
+ (void)context;
+ struct stl_window_kms *kms = al_alloc_object(struct stl_window_kms);
+ stl_window_common_init(&kms->w);
+ kms->w.fullscreen = true;
+ kms->w.create_context = NULL;
+ kms->w.create_window = window_kms_create_window;
+ kms->w.resize_internal = window_kms_resize_internal;
+ kms->w.resize = window_kms_resize;
+ kms->w.toggle_fullscreen = window_kms_toggle_fullscreen;
+#ifdef STELA_POLL_INLINE
+ kms->w.poll = window_kms_poll;
+#ifdef STELA_PAUSE
+ kms->w.wake = window_kms_wake;
+#endif
+#endif
+ kms->w.process_events = window_kms_process_events;
+#ifdef STELA_PAUSE
+ kms->w.should_refresh = window_kms_should_refresh;
+#endif
+ kms->w.free = window_kms_free;
+#if defined STELA_API_VULKAN
+#elif defined STELA_API_OPENGL
+ kms->w.get_gl_proc_address = kmsGetProcAddress;
+ kms->w.gl_loader_load = window_kms_gl_loader_load;
+ kms->w.gl_make_current = window_kms_gl_make_current;
+ kms->w.gl_release_current = window_kms_gl_release_current;
+ kms->w.gl_swap_buffers = window_kms_gl_swap_buffers;
+#elif defined STELA_API_DX11
+#endif
+ return (struct stl_window *)kms;
+ return NULL;
+}
diff --git a/src/window_kms.h b/src/window_kms.h
new file mode 100644
index 0000000..e6b76f9
--- /dev/null
+++ b/src/window_kms.h
@@ -0,0 +1,10 @@
+#pragma once
+
+//#include <xf86drm.h>
+//#include <xf86drmMode.h>
+
+#include "window.h"
+
+struct stl_window_kms {
+ struct stl_window w;
+};
diff --git a/src/window_wayland.c b/src/window_wayland.c
index f07d1ac..07a7067 100644
--- a/src/window_wayland.c
+++ b/src/window_wayland.c
@@ -950,13 +950,7 @@ struct stl_window *stl_window_create(void *context)
(void)context;
al_log_info("stela", "Creating Wayland (EGL) window.");
struct stl_window_wayland *wl = al_alloc_object(struct stl_window_wayland);
-#ifdef STELA_EVENT_BUFFER
- wl->w.data = al_malloc(STELA_EVENTS_SIZE);
- al_ring_buffer_init(&wl->w.events, wl->w.data, STELA_EVENTS_SIZE);
-#endif
-#ifdef STELA_PAUSE
- wl->w.pending_refresh = true;
-#endif
+ stl_window_common_init(&wl->w);
wl->w.fullscreen = false;
wl->w.create_context = window_wayland_create_context;
wl->w.create_window = window_wayland_create_window;
diff --git a/src/window_x11.c b/src/window_x11.c
index ed8d2ae..04a60c2 100644
--- a/src/window_x11.c
+++ b/src/window_x11.c
@@ -338,13 +338,7 @@ struct stl_window *stl_window_create(void *context)
(void)context;
al_log_info("stela", "Creating X11 (EGL) window.");
struct stl_window_x11 *xw = al_alloc_object(struct stl_window_x11);
-#ifdef STELA_EVENT_BUFFER
- xw->w.data = al_malloc(STELA_EVENTS_SIZE);
- al_ring_buffer_init(&xw->w.events, xw->w.data, STELA_EVENTS_SIZE);
-#endif
-#ifdef STELA_PAUSE
- xw->w.pending_refresh = true;
-#endif
+ stl_window_common_init(&xw->w);
xw->w.fullscreen = false;
xw->w.create_context = NULL;
xw->w.create_window = window_x11_create_window;