summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-04-13 08:33:52 +0000
committeronelin <oscar@nelin.dk>2025-04-13 08:41:40 +0000
commit5cd270925af707599a3f842e1e969d5074ae80a8 (patch)
treef5188ad94131824710c2452cc32fee0bc156af2f /src/core
parent0dfd07a115ab626c97080dbe87e3c4904f091041 (diff)
Remove custom vector implementation
cglm go brr
Diffstat (limited to 'src/core')
-rw-r--r--src/core/include/engine/core/platform.h9
-rw-r--r--src/core/include/engine/engine.h3
-rw-r--r--src/core/src/loop.c21
3 files changed, 14 insertions, 19 deletions
diff --git a/src/core/include/engine/core/platform.h b/src/core/include/engine/core/platform.h
index 327bf02..7faf901 100644
--- a/src/core/include/engine/core/platform.h
+++ b/src/core/include/engine/core/platform.h
@@ -5,12 +5,13 @@
extern "C" {
#endif
+#include <cglm/ivec2.h>
+
#include <engine/core/types.h>
#include <engine/core/memory.h>
#include <engine/ctrl/input.h>
#include <engine/rendering/window.h>
#include <engine/resources.h>
-#include <engine/utils/vector.h>
#define NUM_GLOBAL_BINDINGS 1
@@ -30,10 +31,10 @@ typedef struct Instance {
/* TODO: Move mouse data to input ctx/bindings */
/* TODO: Move input ctx/bindings to window */
/* TODO: Move cam to window->renderer */
- v2_i32 mouse_pos;
+ ivec2 mouse_pos;
- v2_i32 mousedown;
- v2_i32 mouseup;
+ ivec2 mousedown;
+ ivec2 mouseup;
bool mouse_lclick;
bool mouse_rclick;
diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h
index d0a61f2..aa4eff6 100644
--- a/src/core/include/engine/engine.h
+++ b/src/core/include/engine/engine.h
@@ -17,7 +17,6 @@ extern "C" {
#include <engine/core/state.h>
#include <engine/ctrl/input.h>
#include <engine/utils/stack.h>
-#include <engine/utils/vector.h>
typedef struct {
u32 texture_id;
@@ -27,7 +26,7 @@ typedef struct {
#include <engine/rendering/window.h>
#include <engine/core/platform.h>
-#include <cglm/cglm.h>
+#include <cglm/ivec2.h>
/* Essential functions */
Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index cd264a7..a17f540 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -4,7 +4,8 @@
#include <string.h>
#include <stdbool.h>
-#include <cglm/cglm.h>
+#include <cglm/ivec2.h>
+#include <cglm/cam.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h>
@@ -91,14 +92,6 @@ i32 cmp_int(const void* a, const void* b) {
return *x - *y;
}
-//v2_i32 get_canvas_size(void* window) {
-// v2_i32 realsize;
-// glfwGetWindowSize(window, &(realsize.x), &(realsize.y));
-//
-// /* Set logical render size */
-// return realsize;
-//}
-
/* Creates the window, initializes IO, Rendering, Fonts and engine-specific
* resources. */
Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
@@ -114,7 +107,7 @@ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
INFO("Starting with pid %lu", pid);
}
#endif
- v2_i32 windowsize = (v2_i32){.x = windowWidth, .y = windowHeight};
+ ivec2 windowsize = {windowWidth, windowHeight};
Instance* p = (Instance*)calloc(1, sizeof(Instance));
Window* w = (Window*)calloc(1, sizeof(Window));
@@ -123,7 +116,7 @@ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
Resources* resources = calloc(1, sizeof(Resources));
// TODO: Initialize them :)
- w = Platform_GLFW.window_init(p, windowtitle, (ivec2){windowsize.x, windowsize.y}, flags);
+ w = Platform_GLFW.window_init(p, windowtitle, (ivec2){windowsize[0], windowsize[1]}, flags);
p->window = w;
p->quit = false;
@@ -142,8 +135,10 @@ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
/* Getting the mouse coords now resolves the issue where a click "isn't
* registered" when the mouse isn't moved before the user clicks */
- p->mousedown = (v2_i32){-1, -1};
- p->mouseup = (v2_i32){-1, -1};
+ p->mousedown[0] = -1;
+ p->mousedown[1] = -1;
+ p->mouseup[0] = -1;
+ p->mouseup[1] = -1;
p->mouse_lclick = false;
p->mouse_rclick = false;