summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/engine/dltools.h2
-rw-r--r--include/engine/engine.h13
-rw-r--r--src/dltools.c1
-rw-r--r--src/engine.c16
-rw-r--r--src/input.c2
5 files changed, 22 insertions, 12 deletions
diff --git a/include/engine/dltools.h b/include/engine/dltools.h
index e883f20..5a53f49 100644
--- a/include/engine/dltools.h
+++ b/include/engine/dltools.h
@@ -1,6 +1,8 @@
#ifndef DLTOOLS_H
#define DLTOOLS_H
+#include <stdbool.h>
+
/* Utility functions for handling runtime linked shared libraries */
bool dynamic_library_close(void* shared_library);
void* dynamic_library_open(const char* library_path);
diff --git a/include/engine/engine.h b/include/engine/engine.h
index a8b5459..6943538 100644
--- a/include/engine/engine.h
+++ b/include/engine/engine.h
@@ -58,8 +58,8 @@ typedef struct {
/* Essential functions */
Platform* engine_init(const char* windowtitle, v2_i32 windowsize,
const f32 render_scale, const u32 flags,
- const usize initial_memory, const FontSpec* fonts[],
- const TextureSpec* textures[]);
+ const usize initial_memory, const Asset_FontSpec* fonts[],
+ const Asset_TextureSpec* textures[]);
i32 engine_run(Platform* p, StateType initial_state);
@@ -76,6 +76,11 @@ u32 get_time(void);
v2_i32 get_windowsize(void);
v2_i32* get_mousepos(void);
+/* Input handling */
+void engine_input_ctx_push(i_ctx* ctx);
+void engine_input_ctx_pop(void);
+void engine_input_ctx_reset(void);
+
#include "rendering.h"
#ifdef ENGINE_INTERNALS
@@ -110,8 +115,8 @@ struct Resources {
usize fontpaths_len;
/* Paths for our sources, kept in case the user wants to reload them */
- TextureSpec** texture_paths;
- FontSpec** font_paths;
+ Asset_TextureSpec** texture_paths;
+ Asset_FontSpec** font_paths;
/* Our actual sources */
Texture** textures;
diff --git a/src/dltools.c b/src/dltools.c
index 2a52f53..1e43b79 100644
--- a/src/dltools.c
+++ b/src/dltools.c
@@ -1,4 +1,3 @@
-#include <stdbool.h>
#include <stdlib.h>
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
diff --git a/src/engine.c b/src/engine.c
index 0bcb8da..af91467 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -64,13 +64,13 @@ v2_i32 get_canvas_size(SDL_Renderer* renderer) {
return realsize;
}
-Texture* load_texture(SDL_Renderer* render, const TextureSpec* ts) {
+Texture* load_texture(SDL_Renderer* render, const Asset_TextureSpec* ts) {
SDL_Texture* new_texture = NULL;
SDL_Surface* loaded_surface = NULL;
Texture* t = NULL;
if (ts == NULL) {
- ERROR("Invalid TextureSpec\n");
+ ERROR("Invalid Asset_TextureSpec\n");
return NULL;
}
@@ -144,8 +144,8 @@ void engine_update_window(Window* w, SDL_WindowEvent* e) {
Platform* engine_init(const char* windowtitle, v2_i32 windowsize,
const f32 render_scale, const u32 flags,
- const usize initial_memory, const FontSpec* fonts[],
- const TextureSpec* textures[]) {
+ const usize initial_memory, const Asset_FontSpec* fonts[],
+ const Asset_TextureSpec* textures[]) {
#ifdef BENCHMARK
u32 init_start = SDL_GetTicks();
@@ -240,8 +240,8 @@ Platform* engine_init(const char* windowtitle, v2_i32 windowsize,
INFO("Number of fonts: " TERM_COLOR_YELLOW "%d" TERM_COLOR_RESET, n_fonts);
/* Save the textures and fonts, if we should need to reload them later */
- resources->texture_paths = (TextureSpec**)textures;
- resources->font_paths = (FontSpec**)fonts;
+ resources->texture_paths = (Asset_TextureSpec**)textures;
+ resources->font_paths = (Asset_FontSpec**)fonts;
/* Allocate memory for textures and fonts */
resources->textures = (Texture**)malloc(sizeof(Texture*) * n_textures);
@@ -716,8 +716,10 @@ void stop(Platform* p) {
SDL_Quit();
}
+/* Set the maximum framerate */
void engine_fps_max(u64 cap) { FPS_CAP = cap; }
+/* Pushes an input context onto the input handling stack */
void engine_input_ctx_push(i_ctx* ctx) {
if (GLOBAL_PLATFORM->bindings == NULL) {
GLOBAL_PLATFORM->bindings = calloc(8, sizeof(i_ctx*));
@@ -758,12 +760,14 @@ void engine_input_ctx_push(i_ctx* ctx) {
GLOBAL_PLATFORM->bindings[GLOBAL_PLATFORM->bindings_len++] = ctx;
}
+/* Pops an input context from the input stack */
void engine_input_ctx_pop(void) {
if (GLOBAL_PLATFORM->bindings == NULL || GLOBAL_PLATFORM->bindings_sz == 0)
return;
i_ctx_t_free(GLOBAL_PLATFORM->bindings[--GLOBAL_PLATFORM->bindings_len]);
}
+/* Removes all input contexts from the input stack */
void engine_input_ctx_reset(void) {
while (GLOBAL_PLATFORM->bindings_len > 0) {
i_ctx_t_free(GLOBAL_PLATFORM->bindings[--GLOBAL_PLATFORM->bindings_len]);
diff --git a/src/input.c b/src/input.c
index f026260..34b1718 100644
--- a/src/input.c
+++ b/src/input.c
@@ -270,7 +270,7 @@ binding_t* get_action(i_ctx* c, action_t* a) {
for (isize i = 0; i < c->len; i++) {
if (c->bindings[i].action.type != a->type) continue;
- switch (c->bindings[i].action) {
+ switch (c->bindings[i].action.type) {
case InputType_error:
return NULL;