aboutsummaryrefslogtreecommitdiff
path: root/src/window/window.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-04-18 12:55:00 +0200
committerdec05eba <dec05eba@protonmail.com>2025-04-18 12:55:00 +0200
commit26c56565cc0573ce23eb8d172a6765bce1f657ce (patch)
treec4ceaacd336946acec12af5f2c5c4d2a78370744 /src/window/window.c
parent506c271eafec23bf469caf6c29431191fa885e58 (diff)
Separate glx and egl from window system to prepare for wayland
Diffstat (limited to 'src/window/window.c')
-rw-r--r--src/window/window.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/window/window.c b/src/window/window.c
index 56df01a..a11bc15 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -1,5 +1,6 @@
#include "../../include/mgl/window/window.h"
-#include "../../include/mgl/window/x11/window.h"
+#include "../../include/mgl/window/x11.h"
+#include "../../include/mgl/window/wayland.h"
#include "../../include/mgl/mgl.h"
#include <stdlib.h>
@@ -8,12 +9,22 @@
#include <string.h>
int mgl_window_init(mgl_window *self, const char *title, const mgl_window_create_params *params, mgl_window_handle existing_window) {
- // TODO: Handle |params->window_system|
memset(self, 0, sizeof(*self));
self->vsync_enabled = true;
self->key_repeat_enabled = true;
mgl_clock_init(&self->frame_timer);
- return mgl_x11_window_init(self, title, params, 0) ? 0 : -1;
+
+ mgl_context *context = mgl_get_context();
+ switch(context->window_system) {
+ case MGL_WINDOW_SYSTEM_NATIVE:
+ assert(false);
+ break;
+ case MGL_WINDOW_SYSTEM_X11:
+ return mgl_window_x11_init(self, title, params, existing_window) ? 0 : -1;
+ case MGL_WINDOW_SYSTEM_WAYLAND:
+ return mgl_window_wayland_init(self, title, params, existing_window) ? 0 : -1;
+ }
+ return -1;
}
int mgl_window_create(mgl_window *self, const char *title, const mgl_window_create_params *params) {
@@ -25,10 +36,12 @@ int mgl_window_init_from_existing_window(mgl_window *self, mgl_window_handle exi
}
void mgl_window_deinit(mgl_window *self) {
- mgl_x11_window_deinit(self);
+ if(self->deinit)
+ self->deinit(self);
}
void mgl_window_clear(mgl_window *self, mgl_color color) {
+ (void)self;
mgl_context *context = mgl_get_context();
context->gl.glClearColor((float)color.r / 255.0f, (float)color.g / 255.0f, (float)color.b / 255.0f, (float)color.a / 255.0f);
context->gl.glClear(GL_COLOR_BUFFER_BIT);