summaryrefslogtreecommitdiff
path: root/src/graphics.h
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-02-10 16:58:26 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-02-10 16:58:26 +0100
commit394cbd934f5771907aeb07480ecb19b9fe618bbd (patch)
tree42eab799a4545d0995408e65c62948e3acc4c602 /src/graphics.h
parent41ce98080cbd98fb2d57b0686ed5297d8fcc9cf3 (diff)
graphics stuff
Diffstat (limited to 'src/graphics.h')
-rw-r--r--src/graphics.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/graphics.h b/src/graphics.h
index 56d16de..0dd916e 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -4,6 +4,7 @@
#include <wayland-egl.h>
#include "utils.h"
+#include "window.h"
enum graphics_error_e : u8 {
GRAPHICS_ERROR_NONE = 0,
@@ -25,10 +26,45 @@ void wayc_graphics_deinit(struct graphics_s* graphics);
enum renderer_error_e : u8 {
RENDERER_ERROR_NONE = 0,
+ RENDERER_ERROR_WINDOW_CREATION,
+ RENDERER_ERROR_SURFACE_CREATION,
};
struct renderer_s {
struct graphics_s* graphics;
- wl_egl_window_t window;
- EGLSurface surface;
+ wl_egl_window_t ewindow;
+ EGLSurface esurface;
+
+ i32 width, height;
};
+
+enum renderer_error_e wayc_renderer_init(struct renderer_s* renderer,
+ struct window_s* window,
+ struct graphics_s* graphics, i32 width,
+ i32 height);
+static inline void wayc_renderer_resize(struct renderer_s* renderer, i32 width,
+ i32 height) {
+ wayc_notnull(renderer);
+ renderer->width = width;
+ renderer->height = height;
+ wl_egl_window_resize(renderer->ewindow, width, height, 0, 0);
+}
+
+static inline void wayc_renderer_use(struct renderer_s* renderer) {
+ wayc_notnull(renderer);
+ struct graphics_s* graphics = renderer->graphics;
+ EGLDisplay display = graphics->display;
+
+ eglMakeCurrent(display, renderer->esurface, renderer->esurface,
+ graphics->context);
+}
+
+static inline void wayc_renderer_swap(struct renderer_s* renderer) {
+ wayc_notnull(renderer);
+ struct graphics_s* graphics = renderer->graphics;
+ EGLDisplay display = graphics->display;
+
+ eglSwapBuffers(display, renderer->esurface);
+}
+
+void wayc_renderer_deinit(struct renderer_s* renderer);