diff options
| author | onelin <oscar@nelin.dk> | 2025-10-31 23:55:42 +0000 |
|---|---|---|
| committer | onelin <oscar@nelin.dk> | 2025-11-02 22:07:17 +0000 |
| commit | d38deeef3af2316a666f8fc0173940bd769b748e (patch) | |
| tree | 6e30d4a9eea18daa5705c894f28cd99ff047e8f9 /src/core/include | |
| parent | 6c077751982ea2c7bd2d9262b01b9f8602f80dc8 (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.
Diffstat (limited to 'src/core/include')
| -rw-r--r-- | src/core/include/engine/core/dltools.h | 23 | ||||
| -rw-r--r-- | src/core/include/engine/core/logging.h | 56 | ||||
| -rw-r--r-- | src/core/include/engine/core/memory.h | 31 | ||||
| -rw-r--r-- | src/core/include/engine/core/platform.h | 44 | ||||
| -rw-r--r-- | src/core/include/engine/core/state.h | 41 | ||||
| -rw-r--r-- | src/core/include/engine/core/types.h | 41 | ||||
| -rw-r--r-- | src/core/include/engine/engine.h | 57 |
7 files changed, 0 insertions, 293 deletions
diff --git a/src/core/include/engine/core/dltools.h b/src/core/include/engine/core/dltools.h deleted file mode 100644 index d9c74ee..0000000 --- a/src/core/include/engine/core/dltools.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef DLTOOLS_H -#define DLTOOLS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#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); -void* dynamic_library_reload(void* shared_library, const char* library_path); - -/* Returns the address of symbol in the provided shared_library handle. - * NULL on error*/ -void* dynamic_library_get_symbol(void* shared_library, const char* symbol); -char* dynamic_library_get_error(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/core/include/engine/core/logging.h b/src/core/include/engine/core/logging.h deleted file mode 100644 index cd55442..0000000 --- a/src/core/include/engine/core/logging.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef LOGGING_H -#define LOGGING_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <math.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <engine/core/types.h> - -#if defined __linux__ || defined __APPLE__ -#define TERM_COLOR_RESET "\033[0m" -#define TERM_COLOR_RED "\033[31m" -#define TERM_COLOR_GREEN "\033[32m" -#define TERM_COLOR_YELLOW "\033[33m" -#define TERM_COLOR_BLUE "\033[34m" -#define TERM_COLOR_PURPLE "\033[35m" -#else -#define TERM_COLOR_RESET -#define TERM_COLOR_RED -#define TERM_COLOR_GREEN -#define TERM_COLOR_YELLOW -#define TERM_COLOR_BLUE -#define TERM_COLOR_PURPLE -#endif - -#define STR(a) (#a) - -void _log(FILE* stream, const char* prefix, const char* fmt, va_list ap); - -void LOG(const char* fmt, ...); - -void INFO_(const char* fmt, ...); -void INFO(const char* fmt, ...); - -#ifdef _DEBUG -#define DEBUG(fmt, ...) __DEBUG(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__) -void __DEBUG(const char* file, const i32 line, const char* func, - const char* fmt, ...); -#else -#define DEBUG(...) -#endif - -void WARN(const char* fmt, ...); - -void ERROR(const char* fmt, ...); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/core/include/engine/core/memory.h b/src/core/include/engine/core/memory.h deleted file mode 100644 index d04d58e..0000000 --- a/src/core/include/engine/core/memory.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef MEMORY_H -#define MEMORY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <engine/core/types.h> - -typedef struct memory { - void* data; - usize size; - usize pos; - usize free; -} memory; - -memory* memory_new(usize max_size); - -/* Returns a pointer to the allocated data */ -void* memory_allocate(memory* mem, usize size); - -memory memory_init(void* data, usize size); - -void memory_free(memory* mem, usize size); - -void memory_clear(memory* mem); - -#ifdef __cplusplus -} -#endif -#endif 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/core/include/engine/core/state.h b/src/core/include/engine/core/state.h deleted file mode 100644 index a6a5e84..0000000 --- a/src/core/include/engine/core/state.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef STATE_H -#define STATE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <engine/core/memory.h> - -typedef enum StateType { - STATE_null, -#define State(name) STATE_##name, -#include <states/list_of_states.h> -#undef State - STATE_quit, -} StateType; - -extern const char* StateTypeStr[]; - -StateType (*State_updateFunc(StateType type))(f64, void*); - -void State_init(StateType type, memory* mem, void* arg); -void* State_free(StateType type, memory* mem); -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> -bool State_reload(StateType type, i_ctx** ctx, usize ctx_len); -bool state_refresh_input_ctx(void* lib, i_ctx** ctx, usize ctx_len); - -#else -#define State_reload(_, _0, _1) true -#define state_refresh_input_ctx(_0, _1, _2) true - -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/core/include/engine/core/types.h b/src/core/include/engine/core/types.h deleted file mode 100644 index a7d794d..0000000 --- a/src/core/include/engine/core/types.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef ENGINE_TYPES_H -#define ENGINE_TYPES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdbool.h> -#include <stdint.h> - -/* Signed */ -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; - -/* Unsigned */ -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -/* floating points */ -typedef float f32; -typedef double f64; - -/* sizes */ -#if __x86_64__ || __ppc64__ || _WIN64 -typedef u64 usize; -typedef i64 isize; -#else -typedef u32 usize; -typedef i32 isize; -#endif - -typedef bool(predicate_t)(const void*); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h deleted file mode 100644 index aa4eff6..0000000 --- a/src/core/include/engine/engine.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef ENGINE_ENGINE_H -#define ENGINE_ENGINE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdbool.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/utils/stack.h> - -typedef struct { - u32 texture_id; - i32 x, y, w, h; -} RenderUnit; - -#include <engine/rendering/window.h> -#include <engine/core/platform.h> - -#include <cglm/ivec2.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 |
