summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--src/core/CMakeLists.txt5
-rw-r--r--src/core/include/engine/core/logging.h2
-rw-r--r--src/core/include/engine/core/memory.h3
-rw-r--r--src/core/include/engine/core/state.h2
-rw-r--r--src/core/include/engine/engine.h19
-rw-r--r--src/core/src/dltools.c5
-rw-r--r--src/core/src/logging.c4
-rw-r--r--src/core/src/loop.c10
-rw-r--r--src/core/src/memory.c5
-rw-r--r--src/core/src/state.c8
-rw-r--r--src/ctrl/CMakeLists.txt2
-rw-r--r--src/ctrl/include/engine/ctrl/input.h2
-rw-r--r--src/ctrl/src/input.c6
-rw-r--r--src/main.c1
-rw-r--r--src/rendering/CMakeLists.txt18
-rw-r--r--src/rendering/include/engine/rendering/rendering.h10
-rw-r--r--src/rendering/src/rendering.c2
-rw-r--r--src/resources/CMakeLists.txt2
-rw-r--r--src/resources/include/engine/resources.h (renamed from src/resources/include/engine/resources/resources.h)2
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/include/engine/ui.h (renamed from src/ui/include/engine/ui/ui.h)6
-rw-r--r--src/ui/src/positioning.c2
-rw-r--r--src/ui/src/rendering.c2
-rw-r--r--src/utils/CMakeLists.txt2
-rw-r--r--src/utils/include/engine/utils.h (renamed from src/utils/include/engine/utils/utils.h)4
-rw-r--r--src/utils/include/engine/utils/fov.h4
-rw-r--r--src/utils/include/engine/utils/hashmap.h8
-rw-r--r--src/utils/include/engine/utils/stack.h2
-rw-r--r--src/utils/include/engine/utils/vector.h2
-rw-r--r--src/utils/src/btree.c2
-rw-r--r--src/utils/src/fov.c2
-rw-r--r--src/utils/src/hashmap.c4
-rw-r--r--src/utils/src/misc.c2
-rw-r--r--src/utils/src/stack.c4
-rw-r--r--src/utils/src/vector.c2
36 files changed, 100 insertions, 68 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5f0b8b5..b474ff7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,13 @@
+set(DAW_INCLUDE_DIRS
+ ${CMAKE_CURRENT_LIST_DIR}/core/include
+ ${CMAKE_CURRENT_LIST_DIR}/ctrl/include
+ ${CMAKE_CURRENT_LIST_DIR}/rendering/include
+ ${CMAKE_CURRENT_LIST_DIR}/resources/include
+ ${CMAKE_CURRENT_LIST_DIR}/ui/include
+ ${CMAKE_CURRENT_LIST_DIR}/utils/include
+ ${CMAKE_BINARY_DIR}/include
+ )
+
add_subdirectory(core)
add_subdirectory(ctrl)
add_subdirectory(rendering)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c6adabf..a9e2b6d 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -9,4 +9,7 @@ add_library(daw_core
src/state.c
)
-target_include_directories(daw_core PRIVATE include)
+set_property(SOURCE src/loop.c APPEND PROPERTY OBJECT_DEPENDS ${GLAD_HEADER})
+
+target_include_directories(daw_core PRIVATE ${DAW_INCLUDE_DIRS})
+target_link_libraries(daw_core PRIVATE cglm)
diff --git a/src/core/include/engine/core/logging.h b/src/core/include/engine/core/logging.h
index d1c5890..52bb446 100644
--- a/src/core/include/engine/core/logging.h
+++ b/src/core/include/engine/core/logging.h
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <string.h>
-#include "types.h"
+#include <engine/core/types.h>
#if defined __linux__ || defined __APPLE__
#define TERM_COLOR_RESET "\033[0m"
diff --git a/src/core/include/engine/core/memory.h b/src/core/include/engine/core/memory.h
index 04c24d5..dbdd065 100644
--- a/src/core/include/engine/core/memory.h
+++ b/src/core/include/engine/core/memory.h
@@ -1,8 +1,7 @@
#ifndef MEMORY_H
#define MEMORY_H
-#include "types.h"
-// #include <stdlib.h>
+#include <engine/core/types.h>
typedef struct memory {
void* data;
diff --git a/src/core/include/engine/core/state.h b/src/core/include/engine/core/state.h
index 13593ed..af94560 100644
--- a/src/core/include/engine/core/state.h
+++ b/src/core/include/engine/core/state.h
@@ -1,7 +1,7 @@
#ifndef STATE_H
#define STATE_H
-#include <engine/memory.h>
+#include <engine/core/memory.h>
typedef enum StateType {
STATE_null,
diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h
index e8a5ace..ba4e227 100644
--- a/src/core/include/engine/engine.h
+++ b/src/core/include/engine/engine.h
@@ -3,14 +3,17 @@
#include <stdbool.h>
-#include <engine/input.h>
-#include <engine/logging.h>
-#include <engine/memory.h>
+// TODO: Cleanup the includes, ideally this header file should only include all
+// "public-facing" headers.
+
+#include <engine/core/types.h>
+#include <engine/core/logging.h>
+#include <engine/core/memory.h>
+#include <engine/core/state.h>
+#include <engine/ctrl/input.h>
#include <engine/resources.h>
-#include <engine/stack.h>
-#include <engine/state.h>
-#include <engine/types.h>
-#include <engine/vector.h>
+#include <engine/utils/stack.h>
+#include <engine/utils/vector.h>
typedef struct {
u32 texture_id;
@@ -83,7 +86,7 @@ void engine_input_ctx_push(i_ctx* ctx);
void engine_input_ctx_pop(void);
void engine_input_ctx_reset(void);
-#include "rendering.h"
+#include <engine/rendering/rendering.h>
#ifdef ENGINE_INTERNALS
diff --git a/src/core/src/dltools.c b/src/core/src/dltools.c
index 1e43b79..d27c4ff 100644
--- a/src/core/src/dltools.c
+++ b/src/core/src/dltools.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <stdbool.h>
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
/* include winapi */
@@ -6,8 +7,8 @@
#include <dlfcn.h>
#endif
-#include <engine/dltools.h>
-#include <engine/logging.h>
+#include <engine/core/dltools.h>
+#include <engine/core/logging.h>
bool dynamic_library_close(void* shared_library) {
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
diff --git a/src/core/src/logging.c b/src/core/src/logging.c
index 7870258..94782ac 100644
--- a/src/core/src/logging.c
+++ b/src/core/src/logging.c
@@ -1,5 +1,5 @@
-#include <engine/logging.h>
-#include <engine/types.h>
+#include <engine/core/logging.h>
+#include <engine/core/types.h>
#include <stdlib.h>
char* itoa(i32 x) {
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index 79e0c0c..837d193 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -25,14 +25,12 @@
#endif
#define ENGINE_INTERNALS
-#include <engine/btree.h>
#include <engine/engine.h>
-#include <engine/hashmap.h>
-#include <engine/list.h>
+#include <engine/utils/btree.h>
+#include <engine/utils/hashmap.h>
+#include <engine/utils/list.h>
-#include <engine/state.h>
-// #include <states/titlescreen.h>
-// #include <states/gameover.h>
+#include <engine/core/state.h>
#define DEFAULT_NUM_PROCS 8
diff --git a/src/core/src/memory.c b/src/core/src/memory.c
index f19803e..7a51a0d 100644
--- a/src/core/src/memory.c
+++ b/src/core/src/memory.c
@@ -2,9 +2,8 @@
#include <stdlib.h>
#include <string.h>
-#include <engine/logging.h>
-
-#include <engine/memory.h>
+#include <engine/core/logging.h>
+#include <engine/core/memory.h>
memory* memory_new(usize max_size) {
memory* m = malloc(sizeof(memory));
diff --git a/src/core/src/state.c b/src/core/src/state.c
index 55f2a12..a2af5e1 100644
--- a/src/core/src/state.c
+++ b/src/core/src/state.c
@@ -1,9 +1,9 @@
#include <string.h>
-#include <engine/dltools.h>
-#include <engine/input.h>
-#include <engine/logging.h>
-#include <engine/state.h>
+#include <engine/core/dltools.h>
+#include <engine/core/logging.h>
+#include <engine/core/state.h>
+#include <engine/ctrl/input.h>
typedef StateType state_update_t(void*);
diff --git a/src/ctrl/CMakeLists.txt b/src/ctrl/CMakeLists.txt
index 7a449d6..3f76069 100644
--- a/src/ctrl/CMakeLists.txt
+++ b/src/ctrl/CMakeLists.txt
@@ -6,4 +6,4 @@ add_library(daw_ctrl
src/mouse.c
)
-target_include_directories(daw_ctrl PRIVATE include)
+target_include_directories(daw_ctrl PRIVATE ${DAW_INCLUDE_DIRS})
diff --git a/src/ctrl/include/engine/ctrl/input.h b/src/ctrl/include/engine/ctrl/input.h
index 49b3a96..26a5f5b 100644
--- a/src/ctrl/include/engine/ctrl/input.h
+++ b/src/ctrl/include/engine/ctrl/input.h
@@ -1,7 +1,7 @@
#ifndef INPUT_H
#define INPUT_H
-#include <engine/types.h>
+#include <engine/core/types.h>
typedef void input_callback_t(void*);
typedef i32 scancode_t;
diff --git a/src/ctrl/src/input.c b/src/ctrl/src/input.c
index 34b1718..2fd025e 100644
--- a/src/ctrl/src/input.c
+++ b/src/ctrl/src/input.c
@@ -1,6 +1,6 @@
-#include <engine/dltools.h>
-#include <engine/input.h>
-#include <engine/logging.h>
+#include <engine/core/dltools.h>
+#include <engine/core/logging.h>
+#include <engine/ctrl/input.h>
#include <string.h>
/* Lazy binds, used internally. They are similar to BindAction and friends.
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..adef7b9
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1 @@
+/* Intentionally left blank for now */
diff --git a/src/rendering/CMakeLists.txt b/src/rendering/CMakeLists.txt
index e04d858..f19cce0 100644
--- a/src/rendering/CMakeLists.txt
+++ b/src/rendering/CMakeLists.txt
@@ -3,9 +3,25 @@ add_library(daw_rendering
src/rendering.c
src/text.c
src/window.c
+ ${GLAD_HEADER}
)
-target_include_directories(daw_rendering PRIVATE include)
+add_custom_command(
+ OUTPUT ${GLAD_HEADER}
+ COMMAND
+ glad
+ --api gl:core=4.6
+ --out-path ${CMAKE_BINARY_DIR}
+ --reproducible
+ c
+ --header-only
+ --mx
+ )
+
+set_property(SOURCE src/window.c APPEND PROPERTY OBJECT_DEPENDS ${GLAD_HEADER})
+set_property(SOURCE src/rendering.c APPEND PROPERTY OBJECT_DEPENDS ${GLAD_HEADER})
+
+target_include_directories(daw_rendering PRIVATE ${DAW_INCLUDE_DIRS})
target_link_libraries(daw_rendering PRIVATE
OpenGL::GL
cglm
diff --git a/src/rendering/include/engine/rendering/rendering.h b/src/rendering/include/engine/rendering/rendering.h
index ff24412..6ae6535 100644
--- a/src/rendering/include/engine/rendering/rendering.h
+++ b/src/rendering/include/engine/rendering/rendering.h
@@ -1,8 +1,8 @@
#ifndef RENDERING_H
#define RENDERING_H
-#include "types.h"
-#include "vector.h"
+#include <engine/core/types.h>
+#include <engine/utils/vector.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
@@ -26,8 +26,8 @@ typedef struct {
} Sprite;
-#include "engine.h"
-#include "ui.h"
+#include <engine/engine.h>
+#include <engine/ui.h>
/* Rendering functions */
void render_begin(Window* w);
@@ -52,7 +52,7 @@ void engine_draw_sprite_ex(Sprite* s, v2_i32* pos, f32 scale,
Sprite sprite_new(u64 tid, u8 coord);
#ifdef ENGINE_INTERNALS
-#include "engine.h"
+#include <engine/engine.h>
//#include <glad/gl.h>
//#define GLFW_INCLUDE_NONE
diff --git a/src/rendering/src/rendering.c b/src/rendering/src/rendering.c
index dff3432..808897c 100644
--- a/src/rendering/src/rendering.c
+++ b/src/rendering/src/rendering.c
@@ -9,7 +9,7 @@
#define ENGINE_INTERNALS
#include <engine/engine.h>
-#include <engine/rendering.h>
+#include <engine/rendering/rendering.h>
/* Extern globals */
extern Platform* GLOBAL_PLATFORM;
diff --git a/src/resources/CMakeLists.txt b/src/resources/CMakeLists.txt
index 02ab1ca..6a99990 100644
--- a/src/resources/CMakeLists.txt
+++ b/src/resources/CMakeLists.txt
@@ -4,4 +4,4 @@ add_library(daw_resources
src/textures.c
)
-target_include_directories(daw_resources PRIVATE include)
+target_include_directories(daw_resources PRIVATE ${DAW_INCLUDE_DIRS})
diff --git a/src/resources/include/engine/resources/resources.h b/src/resources/include/engine/resources.h
index 1689544..9de24ce 100644
--- a/src/resources/include/engine/resources/resources.h
+++ b/src/resources/include/engine/resources.h
@@ -1,7 +1,7 @@
#ifndef RESOURCES_H
#define RESOURCES_H
-#include <engine/types.h>
+#include <engine/core/types.h>
/* We need some "global resources", available to all states.
* These are resources such as common fonts, GUI frames, button background
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 23dcae6..fa91929 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -3,4 +3,4 @@ add_library(daw_ui
src/rendering.c
)
-target_include_directories(daw_ui PRIVATE include)
+target_include_directories(daw_ui PRIVATE ${DAW_INCLUDE_DIRS})
diff --git a/src/ui/include/engine/ui/ui.h b/src/ui/include/engine/ui.h
index 4a3cd3e..eea81af 100644
--- a/src/ui/include/engine/ui/ui.h
+++ b/src/ui/include/engine/ui.h
@@ -1,9 +1,9 @@
#ifndef ENGINE_UI_H
#define ENGINE_UI_H
-#include "list.h"
-#include "types.h"
-#include "vector.h"
+#include <engine/core/types.h>
+#include <engine/utils/list.h>
+#include <engine/utils/vector.h>
#define DIRECTION_HORIZONTAL true
#define DIRECTION_VERTICAL false
diff --git a/src/ui/src/positioning.c b/src/ui/src/positioning.c
index 3db73fe..6bb32fb 100644
--- a/src/ui/src/positioning.c
+++ b/src/ui/src/positioning.c
@@ -1,8 +1,8 @@
#include <stdint.h>
#define ENGINE_INTERNALS
-#include <engine/btree.h>
#include <engine/engine.h>
+#include <engine/utils/btree.h>
#include <engine/utils.h>
static Engine_color DEFAULT_FG = {0xFF, 0xFF, 0xFF, 0xFF};
diff --git a/src/ui/src/rendering.c b/src/ui/src/rendering.c
index 1516736..093f373 100644
--- a/src/ui/src/rendering.c
+++ b/src/ui/src/rendering.c
@@ -5,7 +5,7 @@
#define ENGINE_INTERNALS
#include <engine/engine.h>
-#include <engine/rendering.h>
+#include <engine/rendering/rendering.h>
extern Platform* GLOBAL_PLATFORM;
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
index 7508d26..64f5586 100644
--- a/src/utils/CMakeLists.txt
+++ b/src/utils/CMakeLists.txt
@@ -7,4 +7,4 @@ add_library(daw_utils
src/vector.c
)
-target_include_directories(daw_utils PRIVATE include)
+target_include_directories(daw_utils PRIVATE ${DAW_INCLUDE_DIRS})
diff --git a/src/utils/include/engine/utils/utils.h b/src/utils/include/engine/utils.h
index e537f52..d10a03a 100644
--- a/src/utils/include/engine/utils/utils.h
+++ b/src/utils/include/engine/utils.h
@@ -1,8 +1,8 @@
#ifndef ENGINE_UTILS_H
#define ENGINE_UTILS_H
-#include "types.h"
-#include "vector.h"
+#include <engine/core/types.h>
+#include <engine/utils/vector.h>
#define MIN(a, b) ((a < b) ? (a) : (b))
#define MAX(a, b) ((a > b) ? (a) : (b))
diff --git a/src/utils/include/engine/utils/fov.h b/src/utils/include/engine/utils/fov.h
index 15ef38b..b083d2b 100644
--- a/src/utils/include/engine/utils/fov.h
+++ b/src/utils/include/engine/utils/fov.h
@@ -1,8 +1,8 @@
#ifndef ENGINE_FOV_H
#define ENGINE_FOV_H
-#include "types.h"
-#include "vector.h"
+#include <engine/core/types.h>
+#include <engine/utils/vector.h>
#include <stdbool.h>
/* `fov_shadowcast`: */
diff --git a/src/utils/include/engine/utils/hashmap.h b/src/utils/include/engine/utils/hashmap.h
index bf1d87c..046c810 100644
--- a/src/utils/include/engine/utils/hashmap.h
+++ b/src/utils/include/engine/utils/hashmap.h
@@ -1,12 +1,12 @@
#ifndef ENGINE_HASHMAP_H
#define ENGINE_HASHMAP_H
-#include "types.h"
-
-#include "list.h"
-#include "memory.h"
#include <stdlib.h>
+#include <engine/core/types.h>
+#include <engine/core/memory.h>
+#include <engine/utils/list.h>
+
i32 lolhash(const usize s, i32 v);
/* Define a linked list before using this */
diff --git a/src/utils/include/engine/utils/stack.h b/src/utils/include/engine/utils/stack.h
index 69975df..9fc53aa 100644
--- a/src/utils/include/engine/utils/stack.h
+++ b/src/utils/include/engine/utils/stack.h
@@ -25,7 +25,7 @@
#ifndef STACK_H
#define STACK_H
-#include "types.h"
+#include <engine/core/types.h>
typedef struct {
isize head; /* current number of elements */
diff --git a/src/utils/include/engine/utils/vector.h b/src/utils/include/engine/utils/vector.h
index 58bb0a2..11517dc 100644
--- a/src/utils/include/engine/utils/vector.h
+++ b/src/utils/include/engine/utils/vector.h
@@ -1,7 +1,7 @@
#ifndef VECTOR_H
#define VECTOR_H
-#include "types.h"
+#include <engine/core/types.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/src/utils/src/btree.c b/src/utils/src/btree.c
index c125564..1e85e6c 100644
--- a/src/utils/src/btree.c
+++ b/src/utils/src/btree.c
@@ -1,4 +1,4 @@
-#include <engine/btree.h>
+#include <engine/utils/btree.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/src/utils/src/fov.c b/src/utils/src/fov.c
index 3d5ae16..7bd27e2 100644
--- a/src/utils/src/fov.c
+++ b/src/utils/src/fov.c
@@ -1,4 +1,4 @@
-#include <engine/fov.h>
+#include <engine/utils/fov.h>
#include <engine/utils.h>
#include <math.h>
#include <stdint.h>
diff --git a/src/utils/src/hashmap.c b/src/utils/src/hashmap.c
index 1652bb6..61c5e43 100644
--- a/src/utils/src/hashmap.c
+++ b/src/utils/src/hashmap.c
@@ -1,3 +1,5 @@
-#include <engine/hashmap.h>
+#include <engine/utils/hashmap.h>
+/* Currently, this is a "works, but very poorly" placeholder implementation.
+ * Should be avoided in practice */
i32 lolhash(const usize s, i32 v) { return v % s; }
diff --git a/src/utils/src/misc.c b/src/utils/src/misc.c
index 0f3d218..290c417 100644
--- a/src/utils/src/misc.c
+++ b/src/utils/src/misc.c
@@ -3,7 +3,7 @@
#include <string.h>
-#include <engine/logging.h>
+#include <engine/core/logging.h>
#include <engine/utils.h>
/* These should all be in some external facing module "tools" */
diff --git a/src/utils/src/stack.c b/src/utils/src/stack.c
index ff195ba..a5fc419 100644
--- a/src/utils/src/stack.c
+++ b/src/utils/src/stack.c
@@ -1,5 +1,5 @@
-#include <engine/logging.h>
-#include <engine/stack.h>
+#include <engine/core/logging.h>
+#include <engine/utils/stack.h>
#include <stdlib.h>
Stack stack_new_ex(const usize element_size, const usize size) {
diff --git a/src/utils/src/vector.c b/src/utils/src/vector.c
index 3465df7..5fedb1f 100644
--- a/src/utils/src/vector.c
+++ b/src/utils/src/vector.c
@@ -1,5 +1,5 @@
#include <engine/utils.h>
-#include <engine/vector.h>
+#include <engine/utils/vector.h>
bool v2_i32_eq(const v2_i32 a, const v2_i32 b) {
return (a.x == b.x) && (a.y == b.y);