summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice <fabrice@schaub-dev.xyz>2026-02-10 14:15:22 +0100
committerFabrice <fabrice@schaub-dev.xyz>2026-02-10 14:15:22 +0100
commit8925a2099aa056a917ff31495c5b07d3cd267311 (patch)
tree4101d5e7e22fbb01a4c8b3e9bbe3abc7b496c4a7
parent1acadb9cdfc2025b65b190c872e420b199827655 (diff)
vulkan work
-rw-r--r--src/graphics.cc38
-rw-r--r--src/graphics.h8
-rw-r--r--src/wayclock.cc9
3 files changed, 52 insertions, 3 deletions
diff --git a/src/graphics.cc b/src/graphics.cc
index d0a257a..dc81041 100644
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -1 +1,37 @@
-#include "graphics.h" \ No newline at end of file
+#include "graphics.h"
+
+#include <cstring>
+
+#include "utils.h"
+
+#define WAYC_APP_NAME ""
+#define WAYC_APP_VERSION 0
+
+enum graphics_error_e wayc_graphics_init(struct graphics_s* graphics) {
+ wayc_notnull(graphics);
+ memset(graphics, 0, sizeof(*graphics));
+
+ VkApplicationInfo appinfo = {};
+ appinfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
+ appinfo.pApplicationName = WAYC_APP_NAME;
+ appinfo.applicationVersion = WAYC_APP_VERSION;
+ appinfo.pEngineName = WAYC_APP_NAME;
+ appinfo.engineVersion = WAYC_APP_VERSION;
+
+ VkInstanceCreateInfo createinfo = {};
+ createinfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ createinfo.pApplicationInfo = &appinfo;
+
+ VkResult result = vkCreateInstance(&createinfo, nullptr, &graphics->instance);
+ if (result != VK_SUCCESS) return GRAPHICS_ERROR_INSTANCE;
+
+ graphics->instance = VK_NULL_HANDLE;
+ return GRAPHICS_ERROR_NONE;
+}
+
+void wayc_graphics_deinit(struct graphics_s* graphics) {
+ wayc_notnull(graphics);
+
+ if (graphics->instance == nullptr) return;
+ vkDestroyInstance(graphics->instance, nullptr);
+}
diff --git a/src/graphics.h b/src/graphics.h
index 215fd92..373e302 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -2,6 +2,14 @@
#include <vulkan/vulkan.h>
+enum graphics_error_e {
+ GRAPHICS_ERROR_NONE = 0,
+ GRAPHICS_ERROR_INSTANCE,
+};
+
struct graphics_s {
VkInstance instance;
};
+
+enum graphics_error_e wayc_graphics_init(struct graphics_s* graphics);
+void wayc_graphics_deinit(struct graphics_s* graphics);
diff --git a/src/wayclock.cc b/src/wayclock.cc
index eea9d76..00b6063 100644
--- a/src/wayclock.cc
+++ b/src/wayclock.cc
@@ -1,6 +1,7 @@
#include <cstdio>
#include "events.h"
+#include "graphics.h"
#include "window.h"
#define WAYC_APP_NAME "Wayclock"
@@ -38,12 +39,16 @@ void handle(struct eventloop_s* loop, struct event_s* event) {
}
int main() {
+ struct graphics_s graphics;
+ if (wayc_graphics_init(&graphics) != GRAPHICS_ERROR_NONE)
+ wayc_panic("Failed to initialize graphics");
+
struct eventloop_s loop;
- if (!wayc_eventloop_init(&loop, handle))
+ if (wayc_eventloop_init(&loop, handle) != EVENTLOOP_ERROR_NONE)
wayc_panic("Failed to initialize event loop");
struct window_s window;
- if (!wayc_window_init(&window, WAYC_APP_NAME, &loop)) {
+ if (wayc_window_init(&window, WAYC_APP_NAME, &loop) != WINDOW_ERROR_NONE) {
wayc_eventloop_deinit(&loop);
wayc_panic("Failed to initialize window");
}