summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-10-31 23:55:42 +0000
committeronelin <oscar@nelin.dk>2025-11-02 22:07:17 +0000
commitd38deeef3af2316a666f8fc0173940bd769b748e (patch)
tree6e30d4a9eea18daa5705c894f28cd99ff047e8f9
parent6c077751982ea2c7bd2d9262b01b9f8602f80dc8 (diff)
Flatten project structure
This will make it easier to break up the code into smaller chunks again later. One would think doing this seems fun to me at this point.
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt73
-rw-r--r--src/api/daw.h39
-rw-r--r--src/btree.c (renamed from src/utils/src/btree.c)2
-rw-r--r--src/core/CMakeLists.txt18
-rw-r--r--src/core/include/engine/core/platform.h44
-rw-r--r--src/ctrl/CMakeLists.txt7
-rw-r--r--src/daw.c (renamed from src/core/src/loop.c)22
-rw-r--r--src/dltools.c (renamed from src/core/src/dltools.c)4
-rw-r--r--src/fov.c (renamed from src/utils/src/fov.c)4
-rw-r--r--src/gl.c (renamed from src/rendering/src/gl.c)10
-rw-r--r--src/hashmap.c (renamed from src/utils/src/hashmap.c)2
-rw-r--r--src/include/daw/daw.h (renamed from src/core/include/engine/engine.h)40
-rw-r--r--src/include/daw/dltools.h (renamed from src/core/include/engine/core/dltools.h)0
-rw-r--r--src/include/daw/input.h (renamed from src/ctrl/include/engine/ctrl/input.h)4
-rw-r--r--src/include/daw/keycodes.h (renamed from src/ctrl/include/engine/ctrl/keycodes.h)4
-rw-r--r--src/include/daw/logging.h (renamed from src/core/include/engine/core/logging.h)2
-rw-r--r--src/include/daw/memory.h (renamed from src/core/include/engine/core/memory.h)2
-rw-r--r--src/include/daw/model.h (renamed from src/resources/include/engine/resources/model.h)4
-rw-r--r--src/include/daw/platform.h (renamed from src/rendering/include/engine/rendering/platform.h)5
-rw-r--r--src/include/daw/platform_glfw.h (renamed from src/rendering/include/engine/rendering/platform_glfw.h)6
-rw-r--r--src/include/daw/rendering.h (renamed from src/rendering/include/engine/rendering/rendering.h)44
-rw-r--r--src/include/daw/resources.h (renamed from src/resources/include/engine/resources.h)8
-rw-r--r--src/include/daw/scancodes.h (renamed from src/ctrl/include/engine/ctrl/scancodes.h)0
-rw-r--r--src/include/daw/state.h (renamed from src/core/include/engine/core/state.h)4
-rw-r--r--src/include/daw/texture.h (renamed from src/resources/include/engine/resources/texture.h)6
-rw-r--r--src/include/daw/types.h (renamed from src/core/include/engine/core/types.h)0
-rw-r--r--src/include/daw/utils.h (renamed from src/utils/include/engine/utils.h)2
-rw-r--r--src/include/daw/utils/btree.h (renamed from src/utils/include/engine/utils/btree.h)0
-rw-r--r--src/include/daw/utils/fov.h (renamed from src/utils/include/engine/utils/fov.h)2
-rw-r--r--src/include/daw/utils/hashmap.h (renamed from src/utils/include/engine/utils/hashmap.h)6
-rw-r--r--src/include/daw/utils/list.h (renamed from src/utils/include/engine/utils/list.h)0
-rw-r--r--src/include/daw/utils/stack.h (renamed from src/utils/include/engine/utils/stack.h)2
-rw-r--r--src/include/daw/window.h (renamed from src/rendering/include/engine/rendering/window.h)8
-rw-r--r--src/input.c (renamed from src/ctrl/src/input.c)9
-rw-r--r--src/logging.c (renamed from src/core/src/logging.c)4
-rw-r--r--src/memory.c (renamed from src/core/src/memory.c)4
-rw-r--r--src/misc.c (renamed from src/utils/src/misc.c)4
-rw-r--r--src/model.c (renamed from src/resources/src/model.c)8
-rw-r--r--src/platform_glfw.c (renamed from src/rendering/src/platform_glfw.c)4
-rw-r--r--src/rendering.c (renamed from src/rendering/src/rendering.c)6
-rw-r--r--src/rendering/CMakeLists.txt33
-rw-r--r--src/resources.c (renamed from src/resources/src/resources.c)9
-rw-r--r--src/resources/CMakeLists.txt19
-rw-r--r--src/stack.c (renamed from src/utils/src/stack.c)4
-rw-r--r--src/state.c (renamed from src/core/src/state.c)8
-rw-r--r--src/textures.c (renamed from src/resources/src/textures.c)4
-rw-r--r--src/utils/CMakeLists.txt11
-rw-r--r--src/window.c (renamed from src/rendering/src/window.c)15
-rw-r--r--tools/cmake/DawAddState.cmake8
50 files changed, 244 insertions, 282 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 96d25e0..183a5a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -162,7 +162,7 @@ add_subdirectory(src)
# Configuration files
configure_file(${CMAKE_CURRENT_LIST_DIR}/tools/cmake/configure.h.in
- ${CMAKE_BINARY_DIR}/include/engine/configure.h)
+ ${CMAKE_BINARY_DIR}/include/daw/configure.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/tools/cmake/list_of_states.h.in
${CMAKE_BINARY_DIR}/include/states/list_of_states.h)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8b9cc1d..2e915f8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,25 +1,71 @@
# Set global include dirs
set(DAW_INCLUDE_DIRS
- ${CMAKE_CURRENT_LIST_DIR}/core/include
- ${CMAKE_CURRENT_LIST_DIR}/ctrl/include
+ ${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/rendering/include
- ${CMAKE_CURRENT_LIST_DIR}/resources/include
- ${CMAKE_CURRENT_LIST_DIR}/utils/include
${CMAKE_BINARY_DIR}/include
)
-# Add the engine modules
-add_subdirectory(core)
-add_subdirectory(ctrl)
-add_subdirectory(rendering)
-add_subdirectory(resources)
-add_subdirectory(utils)
+add_custom_command(
+ OUTPUT ${GLAD_HEADER}
+ COMMAND
+ glad
+ --api gl:core=4.6
+ --out-path ${CMAKE_BINARY_DIR}
+ --reproducible
+ c
+ --header-only
+ --mx
+ )
+
# DAW Engine compilation spec
add_library(${PROJECT_NAME}
+ # User facing API
+ api/daw.h
+
+ # Types and (internal) interfaces
+ include/daw/platform.h
+ include/daw/types.h
+
+ # Utility algorithms & datastructures
+ include/daw/utils.h
+ include/daw/utils/list.h
+ btree.c include/daw/utils/btree.h
+ fov.c include/daw/utils/fov.h
+ hashmap.c include/daw/utils/hashmap.h
+ misc.c
+ stack.c include/daw/utils/stack.h
+
+ # Core functionality
+ daw.c include/daw/daw.h
+ dltools.c include/daw/dltools.h
+ logging.c include/daw/logging.h
+ memory.c include/daw/memory.h
+ state.c include/daw/state.h
+
+ # Peripheral IO
+ input.c include/daw/input.h
+ include/daw/keycodes.h
+ include/daw/scancodes.h
+
+ # The rendering & presentation mess
+ gl.c
+ platform_glfw.c include/daw/platform_glfw.h
+ rendering.c include/daw/rendering.h
+ textures.c include/daw/texture.h
+ window.c include/daw/window.h
+
+ # Resource handling
+ model.c include/daw/model.h
+ resources.c include/daw/resources.h
+
+ # Autogenerated header
${GLAD_HEADER}
)
+set_property(SOURCE src/window.c APPEND PROPERTY OBJECT_DEPENDS ${GLAD_HEADER})
+set_property(SOURCE src/rendering.c APPEND PROPERTY OBJECT_DEPENDS ${GLAD_HEADER})
+
set_target_properties(${PROJECT_NAME} PROPERTIES
LINKER_LANGUAGE C
C_STANDARD 99
@@ -27,19 +73,14 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
target_include_directories(${PROJECT_NAME} PUBLIC
include
- # TODO include stb (??)
${CMAKE_BINARY_DIR}/include
)
target_link_libraries(${PROJECT_NAME}
glfw
OpenGL::GL
+ assimp
cglm
- daw_core
- daw_rendering
- daw_ctrl
- daw_resources
- daw_utils
$<$<NOT:$<PLATFORM_ID:Windows>>:m>
$<$<BOOL:${DAW_BUILD_HOTRELOAD}>:dl>
$<$<AND:$<NOT:$<C_COMPILER_ID:MSVC>>,$<BOOL:${DAW_BUILD_UBSAN}>>:ubsan>
diff --git a/src/api/daw.h b/src/api/daw.h
new file mode 100644
index 0000000..25ec177
--- /dev/null
+++ b/src/api/daw.h
@@ -0,0 +1,39 @@
+#ifndef API_DAW_H
+#define API_DAW_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <daw/types.h>
+#include <daw/window.h>
+#include <daw/platform.h>
+
+
+/* Essential functions */
+Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
+ const u32 flags,
+ const usize initial_memory);
+
+i32 engine_run(Instance* p, StateType initial_state, void* state_arg);
+
+void engine_stop(Instance* p);
+
+/* Utility functions */
+void engine_fps_max(Instance* p, u16 cap);
+
+void render_set_zoom(f32 new_zoom);
+void render_adjust_zoom(f32 diff);
+void render_add_unit(RenderUnit* u);
+
+/* move this */
+void delay(uint64_t ms);
+
+// file operations
+usize f_get_sz(FILE* f);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/utils/src/btree.c b/src/btree.c
index 9411072..e4cd0a6 100644
--- a/src/utils/src/btree.c
+++ b/src/btree.c
@@ -1,4 +1,4 @@
-#include <engine/utils/btree.h>
+#include <daw/utils/btree.h>
#include <stdbool.h>
#include <stdio.h>
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
deleted file mode 100644
index a979cad..0000000
--- a/src/core/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-add_library(daw_core
- src/dltools.c
- src/logging.c
- src/loop.c
- src/memory.c
- src/state.c
- ${GLAD_HEADER}
- )
-
-#set_property(SOURCE src/loop.c APPEND PROPERTY OBJECT_DEPENDS ${GLAD_HEADER})
-
-target_compile_options(daw_core PUBLIC ${BUILD_OPTS})
-target_include_directories(daw_core PRIVATE ${DAW_INCLUDE_DIRS})
-target_link_libraries(daw_core PRIVATE cglm)
-
-target_compile_definitions(daw_core PUBLIC
- $<$<BOOL:${DAW_BUILD_HOTRELOAD}>:DAW_BUILD_HOTRELOAD>
-)
diff --git a/src/core/include/engine/core/platform.h b/src/core/include/engine/core/platform.h
deleted file mode 100644
index de39f71..0000000
--- a/src/core/include/engine/core/platform.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef ENGINE_CORE_PLATFORM_H
-#define ENGINE_CORE_PLATFORM_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <cglm/ivec2.h>
-
-#include <engine/core/types.h>
-#include <engine/core/memory.h>
-#include <engine/rendering/window.h>
-#include <engine/resources.h>
-
-#define NUM_GLOBAL_BINDINGS 1
-
-/* Defines the internally used state of the engine.
- * A single instance is created during `engine_init`, and used as a global
- * variable (yeah, im sorry). Due to this design flaw the engine as a whole is
- * not quite thread safe.
- */
-typedef struct Instance {
-
- Window* window;
- bool quit;
-
- u64 frame;
- u16 fps_target;
-
- /* TODO: Move input ctx/bindings to window */
- /* TODO: Move cam to window->renderer */
- Camera *cam;
-
- /* Global resources that live from engine_init to engine_free */
- Resources* resources;
-
- memory* mem;
-
-} Instance;
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/ctrl/CMakeLists.txt b/src/ctrl/CMakeLists.txt
deleted file mode 100644
index f37fa6a..0000000
--- a/src/ctrl/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-add_library(daw_ctrl
- src/input.c
- )
-
-target_compile_options(daw_ctrl PUBLIC ${BUILD_OPTS})
-target_include_directories(daw_ctrl PRIVATE ${DAW_INCLUDE_DIRS} ${GLFW_INCLUDE_DIR})
-target_link_libraries(daw_ctrl PRIVATE cglm glfw)
diff --git a/src/core/src/loop.c b/src/daw.c
index 4e9df36..b632466 100644
--- a/src/core/src/loop.c
+++ b/src/daw.c
@@ -22,19 +22,19 @@
#endif
-#include <engine/configure.h>
+#include <daw/configure.h>
-#include <engine/core/state.h>
-#include <engine/engine.h>
-#include <engine/utils/btree.h>
-#include <engine/utils/hashmap.h>
-#include <engine/utils/list.h>
+#include <daw/state.h>
+#include <daw/daw.h>
+#include <daw/utils/btree.h>
+#include <daw/utils/hashmap.h>
+#include <daw/utils/list.h>
-#include <engine/resources.h>
+#include <daw/resources.h>
-#include <engine/rendering/window.h>
-#include <engine/rendering/rendering.h>
-#include <engine/rendering/platform_glfw.h>
+#include <daw/window.h>
+#include <daw/rendering.h>
+#include <daw/platform_glfw.h>
#define DEFAULT_NUM_PROCS 8
@@ -116,7 +116,7 @@ Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
Resources* resources = calloc(1, sizeof(Resources));
// TODO: Initialize them :)
- w = Window_new(windowtitle,
+ w = Window_new(&Platform_GLFW, windowtitle,
WINDOW_FRAMEWORK_GLFW, WINDOW_RENDERER_OPENGL,
(ivec2){windowsize[0], windowsize[1]}, flags);
diff --git a/src/core/src/dltools.c b/src/dltools.c
index d27c4ff..6a0653a 100644
--- a/src/core/src/dltools.c
+++ b/src/dltools.c
@@ -7,8 +7,8 @@
#include <dlfcn.h>
#endif
-#include <engine/core/dltools.h>
-#include <engine/core/logging.h>
+#include <daw/dltools.h>
+#include <daw/logging.h>
bool dynamic_library_close(void* shared_library) {
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
diff --git a/src/utils/src/fov.c b/src/fov.c
index 90df5af..d7c6746 100644
--- a/src/utils/src/fov.c
+++ b/src/fov.c
@@ -1,5 +1,5 @@
-#include <engine/utils/fov.h>
-#include <engine/utils.h>
+#include <daw/utils/fov.h>
+#include <daw/utils.h>
#include <math.h>
#include <stdint.h>
diff --git a/src/rendering/src/gl.c b/src/gl.c
index 920518f..9dce5e5 100644
--- a/src/rendering/src/gl.c
+++ b/src/gl.c
@@ -4,12 +4,12 @@
#include <glad/gl.h>
-#include <engine/core/types.h>
-#include <engine/core/logging.h>
+#include <daw/types.h>
+#include <daw/logging.h>
-#include <engine/rendering/rendering.h>
-#include <engine/core/platform.h>
-#include <engine/engine.h>
+#include <daw/rendering.h>
+#include <daw/platform.h>
+#include <daw/daw.h>
extern Instance* GLOBAL_PLATFORM;
diff --git a/src/utils/src/hashmap.c b/src/hashmap.c
index f7784d5..653b615 100644
--- a/src/utils/src/hashmap.c
+++ b/src/hashmap.c
@@ -1,4 +1,4 @@
-#include <engine/utils/hashmap.h>
+#include <daw/utils/hashmap.h>
/* Currently, this is a "works, but very poorly" placeholder implementation.
* Should be avoided in practice */
diff --git a/src/core/include/engine/engine.h b/src/include/daw/daw.h
index aa4eff6..acbbcd9 100644
--- a/src/core/include/engine/engine.h
+++ b/src/include/daw/daw.h
@@ -7,26 +7,42 @@ extern "C" {
#include <stdbool.h>
-/* TODO: Cleanup the includes, ideally this header file should only include all
- * "public-facing" headers.
- */
+#include <cglm/ivec2.h>
-#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/utils/stack.h>
+#include <daw/types.h>
+#include <daw/logging.h>
+#include <daw/memory.h>
+#include <daw/state.h>
+#include <daw/input.h>
+#include <daw/utils/stack.h>
+#include <daw/window.h>
+#include <daw/resources.h>
typedef struct {
u32 texture_id;
i32 x, y, w, h;
} RenderUnit;
-#include <engine/rendering/window.h>
-#include <engine/core/platform.h>
+#include <daw/window.h>
-#include <cglm/ivec2.h>
+typedef struct Instance {
+
+ Window* window;
+ bool quit;
+
+ u64 frame;
+ u16 fps_target;
+
+ /* TODO: Move input ctx/bindings to window */
+ /* TODO: Move cam to window->renderer */
+ Camera *cam;
+
+ /* Global resources that live from engine_init to engine_free */
+ Resources* resources;
+
+ memory* mem;
+
+} Instance;
/* Essential functions */
Instance* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight,
diff --git a/src/core/include/engine/core/dltools.h b/src/include/daw/dltools.h
index d9c74ee..d9c74ee 100644
--- a/src/core/include/engine/core/dltools.h
+++ b/src/include/daw/dltools.h
diff --git a/src/ctrl/include/engine/ctrl/input.h b/src/include/daw/input.h
index 18a6797..9fbcd15 100644
--- a/src/ctrl/include/engine/ctrl/input.h
+++ b/src/include/daw/input.h
@@ -6,8 +6,8 @@ extern "C" {
#endif
#include <cglm/ivec2.h>
-#include <engine/core/types.h>
-#include <engine/ctrl/keycodes.h>
+#include <daw/types.h>
+#include <daw/keycodes.h>
typedef void input_callback_t(void*);
typedef i32 scancode_t;
diff --git a/src/ctrl/include/engine/ctrl/keycodes.h b/src/include/daw/keycodes.h
index 4fff38e..869809f 100644
--- a/src/ctrl/include/engine/ctrl/keycodes.h
+++ b/src/include/daw/keycodes.h
@@ -14,8 +14,8 @@ extern "C" {
//
// We want to reserve the following bytes marked with X for the KEYCODE
// 0000 0000 0000 0000 XXXX XXXX XXXX XXXX
-#define KEY_MOD(x) 1 << (32-4 + x)
-#define ACTION(x) (1 << (32-8)) + x
+#define KEY_MOD(x) (1 << (32-4 + x))
+#define ACTION(x) ((1 << (32-8)) + x)
typedef enum {
KEY_SPACE = ' ',
diff --git a/src/core/include/engine/core/logging.h b/src/include/daw/logging.h
index cd55442..65ca827 100644
--- a/src/core/include/engine/core/logging.h
+++ b/src/include/daw/logging.h
@@ -11,7 +11,7 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
-#include <engine/core/types.h>
+#include <daw/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/include/daw/memory.h
index d04d58e..bc10fe2 100644
--- a/src/core/include/engine/core/memory.h
+++ b/src/include/daw/memory.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include <engine/core/types.h>
+#include <daw/types.h>
typedef struct memory {
void* data;
diff --git a/src/resources/include/engine/resources/model.h b/src/include/daw/model.h
index a2fb29c..a78c4b8 100644
--- a/src/resources/include/engine/resources/model.h
+++ b/src/include/daw/model.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include <engine/core/types.h>
+#include <daw/types.h>
typedef enum {
Model_error,
@@ -21,7 +21,7 @@ typedef struct {
unsigned m_uiNumIndices;
} Model;
-#include <engine/resources.h>
+#include <daw/resources.h>
Model load_model(const Asset_ModelSpec *restrict ms);
#ifdef __cplusplus
diff --git a/src/rendering/include/engine/rendering/platform.h b/src/include/daw/platform.h
index ea51c47..c837c63 100644
--- a/src/rendering/include/engine/rendering/platform.h
+++ b/src/include/daw/platform.h
@@ -7,10 +7,9 @@ extern "C" {
#include <cglm/ivec2.h>
-#include <engine/core/types.h>
+#include <daw/types.h>
// TODO: We only need the window once all the garbage in Instance is cleaned up.
-#include <engine/core/platform.h>
-#include <engine/rendering/window.h>
+#include <daw/window.h>
#define DAW_WINDOW_VSYNC (1 << 0)
#define DAW_WINDOW_FULLSCREEN (1 << 1)
diff --git a/src/rendering/include/engine/rendering/platform_glfw.h b/src/include/daw/platform_glfw.h
index 949968d..1136a9f 100644
--- a/src/rendering/include/engine/rendering/platform_glfw.h
+++ b/src/include/daw/platform_glfw.h
@@ -7,9 +7,9 @@ extern "C" {
#include <cglm/ivec2.h>
-#include <engine/core/types.h>
-#include <engine/rendering/platform.h>
-#include <engine/rendering/window.h>
+#include <daw/types.h>
+#include <daw/platform.h>
+#include <daw/window.h>
Window* window_init_glfw(const char *restrict windowtitle, ivec2 windowsize, const u32 flags);
void window_destroy_glfw(Window *restrict w);
diff --git a/src/rendering/include/engine/rendering/rendering.h b/src/include/daw/rendering.h
index a996257..0da97f5 100644
--- a/src/rendering/include/engine/rendering/rendering.h
+++ b/src/include/daw/rendering.h
@@ -5,8 +5,8 @@
extern "C" {
#endif
-#include <engine/core/types.h>
-#include <engine/rendering/window.h>
+#include <daw/types.h>
+#include <daw/window.h>
#include <cglm/ivec2.h>
@@ -63,35 +63,35 @@ typedef enum {
ShaderBufferFlag_none = 0x00,
// First 3 bytes describe the access frequency.
- ShaderBuffer_AccessFrequency_stream = 0b0000000000001, // 1
- ShaderBuffer_AccessFrequency_static = 0b0000000000010, // 2
- ShaderBuffer_AccessFrequency_dynamic = 0b0000000000011, // 3
+ ShaderBuffer_AccessFrequency_stream = 1, // 1
+ ShaderBuffer_AccessFrequency_static = 2, // 2
+ ShaderBuffer_AccessFrequency_dynamic = 3, // 3
// Next 3 bytes describe the access type.
- ShaderBuffer_AccessType_draw = 0b0000000001000, // 8
- ShaderBuffer_AccessType_read = 0b0000000010000, // 16
- ShaderBuffer_AccessType_copy = 0b0000000011000, // 24
+ ShaderBuffer_AccessType_draw = 1 << 3, // 8
+ ShaderBuffer_AccessType_read = 2 << 3, // 16
+ ShaderBuffer_AccessType_copy = 3 << 3, // 24
// Next 3 bytes describe the buffer type
- ShaderBuffer_Type_vertexData = 0b0000001000000, // 64
- ShaderBuffer_Type_vertexPosition = 0b0000010000000, // 128
- ShaderBuffer_Type_vertexIndex = 0b0000011000000, // 192
+ ShaderBuffer_Type_vertexData = 1 << 6, // 64
+ ShaderBuffer_Type_vertexPosition = 2 << 6, // 128
+ ShaderBuffer_Type_vertexIndex = 3 << 6, // 192
// Next 4 bytes are designated for the data type
- ShaderBuffer_DataType_nil = 0b0001000000000, // 512
+ ShaderBuffer_DataType_nil = 1 << 9, // 512
- ShaderBuffer_DataType_f32 = 0b0010000000000, // 1024
- ShaderBuffer_DataType_f64 = 0b0011000000000, // 1536
+ ShaderBuffer_DataType_f32 = 2 << 9, // 1024
+ ShaderBuffer_DataType_f64 = 3 << 9, // 1536
- ShaderBuffer_DataType_i8 = 0b0100000000000, // 2048
- ShaderBuffer_DataType_i16 = 0b0101000000000, // 2560
- ShaderBuffer_DataType_i32 = 0b0110000000000, // 3072
- ShaderBuffer_DataType_i64 = 0b0111000000000, // 3584
+ ShaderBuffer_DataType_i8 = 4 << 9, // 2048
+ ShaderBuffer_DataType_i16 = 5 << 9, // 2560
+ ShaderBuffer_DataType_i32 = 6 << 9, // 3072
+ ShaderBuffer_DataType_i64 = 7 << 9, // 3584
- ShaderBuffer_DataType_u8 = 0b1000000000000, // 4096
- ShaderBuffer_DataType_u16 = 0b1001000000000, // 4608
- ShaderBuffer_DataType_u32 = 0b1010000000000, // 5120
- ShaderBuffer_DataType_u64 = 0b1011000000000, // 5632
+ ShaderBuffer_DataType_u8 = 8 << 9, // 4096
+ ShaderBuffer_DataType_u16 = 9 << 9, // 4608
+ ShaderBuffer_DataType_u32 = 10 << 9, // 5120
+ ShaderBuffer_DataType_u64 = 11 << 9, // 5632
} ShaderBufferFlag;
typedef struct {
diff --git a/src/resources/include/engine/resources.h b/src/include/daw/resources.h
index d967403..90f3b16 100644
--- a/src/resources/include/engine/resources.h
+++ b/src/include/daw/resources.h
@@ -5,8 +5,8 @@
extern "C" {
#endif
-#include <engine/core/types.h>
-#include <engine/rendering/rendering.h>
+#include <daw/types.h>
+#include <daw/rendering.h>
// TODO
/* We need some "global resources", available to all states.
@@ -85,7 +85,7 @@ typedef union {
Asset_ModelSpec model;
} asset_t;
-#include <engine/resources/model.h>
+#include <daw/model.h>
// The resource spec
typedef struct {
@@ -130,7 +130,7 @@ i32 resources_load(Resources *resources);
* to `engine_run` */
isize resource_make_global(isize resource_id);
-#include <engine/resources/texture.h>
+#include <daw/texture.h>
#ifdef __cplusplus
}
diff --git a/src/ctrl/include/engine/ctrl/scancodes.h b/src/include/daw/scancodes.h
index 5b18833..5b18833 100644
--- a/src/ctrl/include/engine/ctrl/scancodes.h
+++ b/src/include/daw/scancodes.h
diff --git a/src/core/include/engine/core/state.h b/src/include/daw/state.h
index a6a5e84..f98d5ff 100644
--- a/src/core/include/engine/core/state.h
+++ b/src/include/daw/state.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include <engine/core/memory.h>
+#include <daw/memory.h>
typedef enum StateType {
STATE_null,
@@ -25,7 +25,7 @@ StateType State_update(StateType type, f64 dt, memory* mem);
/* Reloads shared object file associated with state */
#ifdef DAW_BUILD_HOTRELOAD
-#include <engine/ctrl/input.h>
+#include <daw/input.h>
bool State_reload(StateType type, i_ctx** ctx, usize ctx_len);
bool state_refresh_input_ctx(void* lib, i_ctx** ctx, usize ctx_len);
diff --git a/src/resources/include/engine/resources/texture.h b/src/include/daw/texture.h
index 9f533d6..5904fc1 100644
--- a/src/resources/include/engine/resources/texture.h
+++ b/src/include/daw/texture.h
@@ -5,9 +5,9 @@
extern "C" {
#endif
-#include <engine/core/types.h>
-#include <engine/resources.h>
-#include <engine/rendering/rendering.h>
+#include <daw/types.h>
+#include <daw/resources.h>
+#include <daw/rendering.h>
Texture load_texture(const Asset_TextureSpec *restrict ts);
diff --git a/src/core/include/engine/core/types.h b/src/include/daw/types.h
index a7d794d..a7d794d 100644
--- a/src/core/include/engine/core/types.h
+++ b/src/include/daw/types.h
diff --git a/src/utils/include/engine/utils.h b/src/include/daw/utils.h
index 5096aa4..5f735e9 100644
--- a/src/utils/include/engine/utils.h
+++ b/src/include/daw/utils.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include <engine/core/types.h>
+#include <daw/types.h>
#include <cglm/ivec2.h>
#define MIN(a, b) ((a < b) ? (a) : (b))
diff --git a/src/utils/include/engine/utils/btree.h b/src/include/daw/utils/btree.h
index 1dd2023..1dd2023 100644
--- a/src/utils/include/engine/utils/btree.h
+++ b/src/include/daw/utils/btree.h
diff --git a/src/utils/include/engine/utils/fov.h b/src/include/daw/utils/fov.h
index be64a9e..74ccee8 100644
--- a/src/utils/include/engine/utils/fov.h
+++ b/src/include/daw/utils/fov.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include <engine/core/types.h>
+#include <daw/types.h>
#include <stdbool.h>
#include <cglm/ivec2.h>
diff --git a/src/utils/include/engine/utils/hashmap.h b/src/include/daw/utils/hashmap.h
index 0113ce5..15ec5f0 100644
--- a/src/utils/include/engine/utils/hashmap.h
+++ b/src/include/daw/utils/hashmap.h
@@ -7,9 +7,9 @@ extern "C" {
#include <stdlib.h>
-#include <engine/core/types.h>
-#include <engine/core/memory.h>
-#include <engine/utils/list.h>
+#include <daw/types.h>
+#include <daw/memory.h>
+#include <daw/utils/list.h>
usize lolhash(const usize s, usize v);
diff --git a/src/utils/include/engine/utils/list.h b/src/include/daw/utils/list.h
index 04dda04..04dda04 100644
--- a/src/utils/include/engine/utils/list.h
+++ b/src/include/daw/utils/list.h
diff --git a/src/utils/include/engine/utils/stack.h b/src/include/daw/utils/stack.h
index b4caf5f..004e686 100644
--- a/src/utils/include/engine/utils/stack.h
+++ b/src/include/daw/utils/stack.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-#include <engine/core/types.h>
+#include <daw/types.h>
typedef struct {
usize head; /* current number of elements */
diff --git a/src/rendering/include/engine/rendering/window.h b/src/include/daw/window.h
index a964b38..2924448 100644
--- a/src/rendering/include/engine/rendering/window.h
+++ b/src/include/daw/window.h
@@ -7,8 +7,8 @@ extern "C" {
#include <cglm/ivec2.h>
-#include <engine/core/types.h>
-#include <engine/ctrl/input.h>
+#include <daw/types.h>
+#include <daw/input.h>
#ifndef ENGINE_RENDERING_WINDOW_H_EXCLUDE_EXTERNS
extern u64 (*get_time)(void);
@@ -43,7 +43,9 @@ typedef struct {
i_ctx** bindings;
} Window;
-Window* Window_new(const char *restrict title, Window_framework framework, Window_renderer renderer, ivec2 size, u32 flags);
+#include <daw/platform.h>
+
+Window* Window_new(const struct Platform *p, const char *restrict title, Window_framework framework, Window_renderer renderer, ivec2 size, u32 flags);
void get_mousepos(double *x, double *y);
diff --git a/src/ctrl/src/input.c b/src/input.c
index 52d5ce4..b33a1fa 100644
--- a/src/ctrl/src/input.c
+++ b/src/input.c
@@ -4,10 +4,11 @@
#undef GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
-#include <engine/core/dltools.h>
-#include <engine/core/logging.h>
-#include <engine/core/platform.h>
-#include <engine/ctrl/input.h>
+#include <daw/daw.h>
+#include <daw/dltools.h>
+#include <daw/logging.h>
+#include <daw/platform.h>
+#include <daw/input.h>
extern input_callback_t* callbacks[128];
extern usize callbacks_len;
diff --git a/src/core/src/logging.c b/src/logging.c
index 94782ac..c5eec18 100644
--- a/src/core/src/logging.c
+++ b/src/logging.c
@@ -1,5 +1,5 @@
-#include <engine/core/logging.h>
-#include <engine/core/types.h>
+#include <daw/logging.h>
+#include <daw/types.h>
#include <stdlib.h>
char* itoa(i32 x) {
diff --git a/src/core/src/memory.c b/src/memory.c
index 7a51a0d..8dc14eb 100644
--- a/src/core/src/memory.c
+++ b/src/memory.c
@@ -2,8 +2,8 @@
#include <stdlib.h>
#include <string.h>
-#include <engine/core/logging.h>
-#include <engine/core/memory.h>
+#include <daw/logging.h>
+#include <daw/memory.h>
memory* memory_new(usize max_size) {
memory* m = malloc(sizeof(memory));
diff --git a/src/utils/src/misc.c b/src/misc.c
index 063efbf..16c0cfb 100644
--- a/src/utils/src/misc.c
+++ b/src/misc.c
@@ -3,8 +3,8 @@
#include <string.h>
-#include <engine/core/logging.h>
-#include <engine/utils.h>
+#include <daw/logging.h>
+#include <daw/utils.h>
/* These should all be in some external facing module "tools" */
diff --git a/src/resources/src/model.c b/src/model.c
index 7244e63..172c409 100644
--- a/src/resources/src/model.c
+++ b/src/model.c
@@ -1,6 +1,6 @@
-#include <engine/engine.h>
-#include <engine/core/logging.h>
-#include <engine/resources/model.h>
+#include <daw/daw.h>
+#include <daw/logging.h>
+#include <daw/model.h>
#include <assimp/cimport.h>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
@@ -58,7 +58,7 @@ Model load_model(const Asset_ModelSpec *restrict ms) {
aiReleaseImport(scene);
{
- Model m = {};
+ Model m = {0};
m.format = format;
// TODO add index array
diff --git a/src/rendering/src/platform_glfw.c b/src/platform_glfw.c
index 47638e2..211df47 100644
--- a/src/rendering/src/platform_glfw.c
+++ b/src/platform_glfw.c
@@ -9,9 +9,9 @@
#undef GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
-#include <engine/core/logging.h>
+#include <daw/logging.h>
-#include <engine/rendering/platform.h>
+#include <daw/platform.h>
static void window_resize_callback(GLFWwindow *restrict window, int width, int height);
static void framebuffer_resize_callback(GLFWwindow *restrict window, int width, int height);
diff --git a/src/rendering/src/rendering.c b/src/rendering.c
index 8932cfc..54dc7b4 100644
--- a/src/rendering/src/rendering.c
+++ b/src/rendering.c
@@ -8,9 +8,9 @@
#include <cglm/mat4.h>
-#include <engine/engine.h>
-#include <engine/utils.h>
-#include <engine/rendering/rendering.h>
+#include <daw/daw.h>
+#include <daw/utils.h>
+#include <daw/rendering.h>
/* Extern globals */
diff --git a/src/rendering/CMakeLists.txt b/src/rendering/CMakeLists.txt
deleted file mode 100644
index f3f4710..0000000
--- a/src/rendering/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-add_library(daw_rendering
- src/gl.c
- src/rendering.c
- src/window.c
- src/platform_glfw.c
- ${GLAD_HEADER}
- )
-
-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_compile_options(daw_rendering PUBLIC ${BUILD_OPTS})
-target_include_directories(daw_rendering PRIVATE
- ${DAW_INCLUDE_DIRS}
- ${GLFW_INCLUDE_DIR}
-)
-target_link_libraries(daw_rendering PRIVATE
- OpenGL::GL
- cglm
- glfw
-)
diff --git a/src/resources/src/resources.c b/src/resources.c
index 6e35a4f..49b20e0 100644
--- a/src/resources/src/resources.c
+++ b/src/resources.c
@@ -1,9 +1,10 @@
#include <string.h>
-#include <engine/core/types.h>
-#include <engine/core/logging.h>
-#include <engine/core/platform.h>
-#include <engine/resources.h>
+#include <daw/types.h>
+#include <daw/daw.h>
+#include <daw/logging.h>
+#include <daw/platform.h>
+#include <daw/resources.h>
extern Instance* GLOBAL_PLATFORM;
diff --git a/src/resources/CMakeLists.txt b/src/resources/CMakeLists.txt
deleted file mode 100644
index 4d3ee22..0000000
--- a/src/resources/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-## Uncomment the following to fetch and build assimp.
-#FetchContent_Declare(assimp
-# GIT_REPOSITORY https://github.com/assimp/assimp.git
-# GIT_TAG v5.3.1
-#)
-#FetchContent_MakeAvailable(assimp)
-
-add_library(daw_resources
- src/resources.c
- src/textures.c
- src/model.c
- )
-
-target_compile_options(daw_resources PUBLIC ${BUILD_OPTS})
-target_include_directories(daw_resources PRIVATE ${DAW_INCLUDE_DIRS} stb)
-target_link_libraries(daw_resources PRIVATE
- assimp
- cglm
- )
diff --git a/src/utils/src/stack.c b/src/stack.c
index a7cb16d..f0023c4 100644
--- a/src/utils/src/stack.c
+++ b/src/stack.c
@@ -1,5 +1,5 @@
-#include <engine/core/logging.h>
-#include <engine/utils/stack.h>
+#include <daw/logging.h>
+#include <daw/utils/stack.h>
#include <stdlib.h>
Stack stack_new_ex(const usize element_size, const usize size) {
diff --git a/src/core/src/state.c b/src/state.c
index a206cbb..08d9f37 100644
--- a/src/core/src/state.c
+++ b/src/state.c
@@ -1,9 +1,9 @@
#include <string.h>
-#include <engine/core/dltools.h>
-#include <engine/core/logging.h>
-#include <engine/core/state.h>
-#include <engine/ctrl/input.h>
+#include <daw/dltools.h>
+#include <daw/logging.h>
+#include <daw/state.h>
+#include <daw/input.h>
//typedef void state_init_t(void*,void*);
//typedef void* (state_free_t(void*));
diff --git a/src/resources/src/textures.c b/src/textures.c
index 913c931..5b23e7a 100644
--- a/src/resources/src/textures.c
+++ b/src/textures.c
@@ -1,5 +1,5 @@
-#include <engine/core/logging.h>
-#include <engine/resources.h>
+#include <daw/logging.h>
+#include <daw/resources.h>
#include <stb/stb_image.h>
/* Uses stb_image to load an image, and passes it to the renderer for
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
deleted file mode 100644
index 6acdba1..0000000
--- a/src/utils/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-add_library(daw_utils
- src/btree.c
- src/fov.c
- src/hashmap.c
- src/misc.c
- src/stack.c
- )
-
-target_compile_options(daw_utils PUBLIC ${BUILD_OPTS})
-target_include_directories(daw_utils PRIVATE ${DAW_INCLUDE_DIRS})
-target_link_libraries(daw_utils PRIVATE cglm)
diff --git a/src/rendering/src/window.c b/src/window.c
index d761543..ea42678 100644
--- a/src/rendering/src/window.c
+++ b/src/window.c
@@ -1,17 +1,15 @@
#include <time.h>
/* TODO: REMOVE THIS INCLUSION */
-#include <engine/engine.h>
+#include <daw/daw.h>
-#include <engine/core/types.h>
-#include <engine/core/logging.h>
+#include <daw/types.h>
+#include <daw/logging.h>
#define ENGINE_RENDERING_WINDOW_H_EXCLUDE_EXTERNS
-#include <engine/rendering/window.h>
+#include <daw/window.h>
#undef ENGINE_RENDERING_WINDOW_H_EXCLUDE_EXTERNS
-#include <engine/rendering/platform_glfw.h>
-
#include <glad/gl.h>
#undef GLFW_INCLUDE_NONE
@@ -40,7 +38,8 @@ u64 (*get_time)(void) = platform_get_time_usec;
#define DAW_WINDOW_RESIZEABLE (1 << 2)
// Wrapper to get a specific window and set up related structures.
-Window* Window_new(const char *restrict title, Window_framework framework, Window_renderer renderer, ivec2 size, u32 flags) {
+// What the fuck is this doing here.
+Window* Window_new(const struct Platform* p, const char *restrict title, Window_framework framework, Window_renderer renderer, ivec2 size, u32 flags) {
Window* w = NULL;
switch (framework) {
@@ -49,7 +48,7 @@ Window* Window_new(const char *restrict title, Window_framework framework, Windo
case WINDOW_RENDERER_OPENGL:
/* For now, pass instance as NULL, fix it once all the necessary bs is
* out of struct Instance */
- w = Platform_GLFW.window_init(title, size, flags);
+ w = p->window_init(title, size, flags);
w->bindings = NULL;
w->bindings_sz = 0;
diff --git a/tools/cmake/DawAddState.cmake b/tools/cmake/DawAddState.cmake
index 213b77b..902e814 100644
--- a/tools/cmake/DawAddState.cmake
+++ b/tools/cmake/DawAddState.cmake
@@ -15,7 +15,7 @@
# Then call `daw_add_state(${STATENAME}) for each of your states.
macro(daw_add_state STATENAME)
# Add state include directory to the engines target
- set_property(TARGET daw_core
+ set_property(TARGET daw
APPEND PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/state_${STATENAME}/include)
@@ -54,7 +54,7 @@ macro(daw_add_state STATENAME)
add_library(${STATENAME} OBJECT ${STATE_SOURCES})
# The game-state source is withing the core module
- set_property(TARGET daw_core
+ set_property(TARGET daw
APPEND PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/state_${STATENAME}/include
)
@@ -64,10 +64,6 @@ macro(daw_add_state STATENAME)
cglm
)
- set_property(TARGET daw_core
- APPEND PROPERTY LINK_LIBRARIES
- ${STATENAME})
-
set_property(TARGET daw
APPEND PROPERTY LINK_LIBRARIES
${STATENAME})