diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/include/engine/core/platform.h | 6 | ||||
| -rw-r--r-- | src/core/include/engine/engine.h | 8 | ||||
| -rw-r--r-- | src/core/src/loop.c | 21 |
3 files changed, 14 insertions, 21 deletions
diff --git a/src/core/include/engine/core/platform.h b/src/core/include/engine/core/platform.h index e0d2419..2e74fbe 100644 --- a/src/core/include/engine/core/platform.h +++ b/src/core/include/engine/core/platform.h @@ -5,6 +5,7 @@ #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 @@ -15,8 +16,6 @@ * not quite thread safe. */ typedef struct Platform { - void* data; /* Contains textures and such */ - u64 data_len; Window window; bool quit; @@ -36,6 +35,9 @@ typedef struct Platform { i32 camera_x; i32 camera_y; + /* Global resources that live from engine_init to engine_free */ + Resources* resources; + /* Text input/editing is currently not used/implemented */ char* edit_text; usize edit_pos; diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h index 11ee096..d5b0922 100644 --- a/src/core/include/engine/engine.h +++ b/src/core/include/engine/engine.h @@ -1,5 +1,5 @@ -#ifndef ENGINE_H -#define ENGINE_H +#ifndef ENGINE_ENGINE_H +#define ENGINE_ENGINE_H #include <stdbool.h> @@ -12,7 +12,6 @@ #include <engine/core/memory.h> #include <engine/core/state.h> #include <engine/ctrl/input.h> -#include <engine/resources.h> #include <engine/utils/stack.h> #include <engine/utils/vector.h> @@ -27,8 +26,7 @@ typedef struct { /* Essential functions */ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight, const f32 render_scale, const u32 flags, - const usize initial_memory, const Asset_FontSpec* fonts[], - const Asset_TextureSpec* textures[]); + const usize initial_memory); i32 engine_run(Platform* p, StateType initial_state, void* state_arg); diff --git a/src/core/src/loop.c b/src/core/src/loop.c index 3974c78..f29ef25 100644 --- a/src/core/src/loop.c +++ b/src/core/src/loop.c @@ -23,6 +23,8 @@ #include <engine/utils/hashmap.h> #include <engine/utils/list.h> +#include <engine/resources.h> + #include <engine/rendering/window.h> #include <engine/rendering/rendering.h> @@ -72,8 +74,7 @@ void engine_update_window(Window* w, void* e) { * resources. */ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight, const f32 render_scale, const u32 flags, - const usize initial_memory, const Asset_FontSpec* fonts[], - const Asset_TextureSpec* textures[]) { + const usize initial_memory) { #if defined(__linux) || defined(__linux__) || defined(linux) { @@ -87,16 +88,8 @@ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight Window w = (Window)malloc(sizeof(Window)); /* initialize resources */ - struct Resources* resources = - (struct Resources*)malloc(sizeof(struct Resources)); - //resources->textures_len = 0; - //resources->fonts_len = 0; - //resources->texturepaths_len = 0; - //resources->fontpaths_len = 0; - //resources->texture_paths = NULL; - //resources->font_paths = NULL; - //resources->textures = NULL; - //resources->fonts = NULL; + Resources* resources = malloc(sizeof(Resources)); + // TODO: Initialize them :) w = init_window_glfw(windowtitle, (ivec2){windowsize.x, windowsize.y}, flags); // Dont forget to init the renderer @@ -317,11 +310,11 @@ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight // INFO("Windowsize: <%d,%d>", windowsize.x, windowsize.y); //} - p->data = (void*)resources; - p->data_len = sizeof(struct Resources); p->window = w; p->quit = false; + p->resources = resources; + p->frame = 0; p->fps_target = 60; |
