From 5cd270925af707599a3f842e1e969d5074ae80a8 Mon Sep 17 00:00:00 2001 From: onelin Date: Sun, 13 Apr 2025 10:33:52 +0200 Subject: Remove custom vector implementation cglm go brr --- src/core/include/engine/core/platform.h | 9 +++++---- src/core/include/engine/engine.h | 3 +-- src/core/src/loop.c | 21 ++++++++------------- 3 files changed, 14 insertions(+), 19 deletions(-) (limited to 'src/core') 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 + #include #include #include #include #include -#include #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 #include #include -#include typedef struct { u32 texture_id; @@ -27,7 +26,7 @@ typedef struct { #include #include -#include +#include /* 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 #include -#include +#include +#include #define STB_IMAGE_IMPLEMENTATION #include @@ -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; -- cgit v1.3