summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/include/engine/core/platform.h8
-rw-r--r--src/core/include/engine/engine.h8
-rw-r--r--src/core/src/loop.c12
-rw-r--r--src/ctrl/src/input.c2
-rw-r--r--src/rendering/include/engine/rendering/window.h5
-rw-r--r--src/rendering/src/gl.c2
-rw-r--r--src/rendering/src/rendering.c2
-rw-r--r--src/rendering/src/window.c6
-rw-r--r--src/resources/src/resources.c2
9 files changed, 25 insertions, 22 deletions
diff --git a/src/core/include/engine/core/platform.h b/src/core/include/engine/core/platform.h
index 675766b..327bf02 100644
--- a/src/core/include/engine/core/platform.h
+++ b/src/core/include/engine/core/platform.h
@@ -19,7 +19,7 @@ extern "C" {
* variable (yeah, im sorry). Due to this design flaw the engine as a whole is
* not quite thread safe.
*/
-typedef struct Platform {
+typedef struct Instance {
Window* window;
bool quit;
@@ -27,7 +27,9 @@ typedef struct Platform {
u64 frame;
u16 fps_target;
- /* TODO: Move mouse data to input ctx */
+ /* 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;
v2_i32 mousedown;
@@ -49,7 +51,7 @@ typedef struct Platform {
usize bindings_len;
binding_t bindings_global[NUM_GLOBAL_BINDINGS];
-} Platform;
+} Instance;
#ifdef __cplusplus
}
diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h
index 0b1a540..d28c024 100644
--- a/src/core/include/engine/engine.h
+++ b/src/core/include/engine/engine.h
@@ -30,16 +30,16 @@ typedef struct {
#include <cglm/cglm.h>
/* Essential functions */
-Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
+Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
const f32 render_scale, const u32 flags,
const usize initial_memory);
-i32 engine_run(Platform* p, StateType initial_state, void* state_arg);
+i32 engine_run(Instance* p, StateType initial_state, void* state_arg);
-void engine_stop(Platform* p);
+void engine_stop(Instance* p);
/* Utility functions */
-void engine_fps_max(Platform* p, u16 cap);
+void engine_fps_max(Instance* p, u16 cap);
void render_set_zoom(f32 new_zoom);
void render_adjust_zoom(f32 diff);
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index cff8d64..6a91f46 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -37,7 +37,7 @@
#define DEFAULT_NUM_PROCS 8
-Platform* GLOBAL_PLATFORM = NULL;
+Instance* GLOBAL_PLATFORM = NULL;
static Camera default_camera = {
.pos = {3, 0, 0},
@@ -100,7 +100,7 @@ i32 cmp_int(const void* a, const void* b) {
/* Creates the window, initializes IO, Rendering, Fonts and engine-specific
* resources. */
-Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
+Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
const f32 render_scale, const u32 flags,
const usize initial_memory) {
@@ -115,7 +115,7 @@ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
#endif
v2_i32 windowsize = (v2_i32){.x = windowWidth, .y = windowHeight};
- Platform* p = (Platform*)calloc(1, sizeof(Platform));
+ Instance* p = (Instance*)calloc(1, sizeof(Instance));
Window* w = (Window*)calloc(1, sizeof(Window));
/* initialize resources */
@@ -275,7 +275,7 @@ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
return p;
}
-i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
+i32 engine_run(Instance* p, StateType initial_state, void* state_arg) {
if (p == NULL) {
ERROR("Platform is uninitialized.\n");
@@ -396,7 +396,7 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
return 0;
}
-void engine_stop(Platform* p) {
+void engine_stop(Instance* p) {
if (p == NULL) return;
//{ /* Deallocate resources */
@@ -419,7 +419,7 @@ void engine_stop(Platform* p) {
}
/* Set the maximum framerate */
-void engine_fps_max(Platform* p, u16 cap) {
+void engine_fps_max(Instance* p, u16 cap) {
LOG("Setting max fps to %llu", cap);
p->fps_target = cap;
}
diff --git a/src/ctrl/src/input.c b/src/ctrl/src/input.c
index 844fd2c..9da4114 100644
--- a/src/ctrl/src/input.c
+++ b/src/ctrl/src/input.c
@@ -12,7 +12,7 @@
extern input_callback_t* callbacks[128];
extern usize callbacks_len;
-extern Platform* GLOBAL_PLATFORM;
+extern Instance* GLOBAL_PLATFORM;
/* Lazy binds, used internally. They are similar to BindAction and friends.
* The only difference is that we set callbacks and such to NULL, but populate
* the function name strings such that can be reloaded. */
diff --git a/src/rendering/include/engine/rendering/window.h b/src/rendering/include/engine/rendering/window.h
index c902cad..edb510a 100644
--- a/src/rendering/include/engine/rendering/window.h
+++ b/src/rendering/include/engine/rendering/window.h
@@ -5,9 +5,10 @@
extern "C" {
#endif
-#include <engine/core/types.h>
#include <cglm/cglm.h>
+#include <engine/core/types.h>
+
#ifndef ENGINE_RENDERING_WINDOW_H_EXCLUDE_EXTERNS
extern void (*window_poll_events)(void);
extern u64 (*get_time)(void);
@@ -27,6 +28,7 @@ typedef struct {
// Specifies the framwork & renderer combo used.
Window_framework framework;
Window_renderer renderer;
+
// Window *buffer* size, in pixels.
ivec2 windowsize;
@@ -48,7 +50,6 @@ void init_render_opengl(Window* w, const u32 flags);
void get_mousepos(double *x, double *y);
-#undef API
#ifdef __cplusplus
}
#endif
diff --git a/src/rendering/src/gl.c b/src/rendering/src/gl.c
index 92599d7..920518f 100644
--- a/src/rendering/src/gl.c
+++ b/src/rendering/src/gl.c
@@ -11,7 +11,7 @@
#include <engine/core/platform.h>
#include <engine/engine.h>
-extern Platform* GLOBAL_PLATFORM;
+extern Instance* GLOBAL_PLATFORM;
const char* ShaderType_str[] = {
[Shader_Error] = "Shader_Error",
diff --git a/src/rendering/src/rendering.c b/src/rendering/src/rendering.c
index 0403928..424d3d5 100644
--- a/src/rendering/src/rendering.c
+++ b/src/rendering/src/rendering.c
@@ -11,7 +11,7 @@
/* Extern globals */
-extern Platform* GLOBAL_PLATFORM;
+extern Instance* GLOBAL_PLATFORM;
/* Globals */
#define drawcall_limit (64 * 1024)
diff --git a/src/rendering/src/window.c b/src/rendering/src/window.c
index 9f5e861..3d163eb 100644
--- a/src/rendering/src/window.c
+++ b/src/rendering/src/window.c
@@ -19,7 +19,7 @@
#include <cglm/cglm.h>
-extern Platform* GLOBAL_PLATFORM;
+extern Instance* GLOBAL_PLATFORM;
void (*window_poll_events)(void) = NULL;
@@ -71,12 +71,12 @@ GladGLContext* create_context(GLFWwindow *window) {
}
/* Should honestly just write my own */
-static inline u64 glfw_gettime_msec() {
+static inline u64 glfw_gettime_msec(void) {
return (u64)(glfwGetTime() * 1000.0);
}
/* Should honestly just write my own */
-static inline u64 glfw_gettime_usec() {
+static inline u64 glfw_gettime_usec(void) {
return (u64)(glfwGetTime() * 1000000.0);
}
diff --git a/src/resources/src/resources.c b/src/resources/src/resources.c
index ba28cd8..52546db 100644
--- a/src/resources/src/resources.c
+++ b/src/resources/src/resources.c
@@ -5,7 +5,7 @@
#include <engine/core/platform.h>
#include <engine/resources.h>
-extern Platform* GLOBAL_PLATFORM;
+extern Instance* GLOBAL_PLATFORM;
extern const char* ShaderType_str[];