From 8c034c4a2642785fef1fa1816b6ff0c99cf9dda5 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 17 Dec 2024 02:38:06 +0100 Subject: [PATCH] optimized build script and started to split shaders. not yet working, opengl only handles one asset file and vulkan and directx still need the remaining code impl. --- asset/AssetArchive.h | 8 ++++++- camera/Camera.h | 8 +++++-- font/Font.h | 7 +++++- gpuapi/RenderUtils.h | 4 ++-- gpuapi/direct3d/GpuApiContainer.h | 33 ++++++++++++++++++++++++++++ gpuapi/opengl/GpuApiContainer.h | 15 +++++++++++++ gpuapi/vulkan/GpuApiContainer.h | 28 ++++++++++++++++++++++++ image/Image.cpp | 2 +- log/Debug.cpp | 4 +++- math/matrix/VectorFloat32.h | 7 +++++- math/matrix/VectorFloat64.h | 7 +++++- math/matrix/VectorInt32.h | 7 +++++- math/matrix/VectorInt64.h | 7 +++++- memory/Queue.h | 5 +++++ memory/ThreadedQueue.h | 5 +++++ models/settings/setting_types.h | 5 ----- object/Mesh.h | 10 ++++++++- platform/linux/SystemInfo.cpp | 9 ++++++-- platform/win32/Library.h | 2 +- platform/win32/SystemInfo.cpp | 9 ++++++-- platform/win32/UtilsWindows.h | 9 +++++--- platform/win32/Window.h | 20 +++-------------- platform/win32/input/RawInput.h | 4 +--- stdlib/HashMap.h | 4 ++++ stdlib/IntrinsicsArm.h | 16 -------------- stdlib/PerfectHashMap.h | 0 stdlib/Types.h | 4 ++++ {platform => system}/Library.h | 4 ++-- {platform => system}/SystemInfo.h | 4 ++-- system/Window.h | 32 +++++++++++++++++++++++++++ utils/StringUtils.h | 36 +++++++++++++++++++++++++++++++ 31 files changed, 249 insertions(+), 66 deletions(-) create mode 100644 gpuapi/direct3d/GpuApiContainer.h create mode 100644 gpuapi/opengl/GpuApiContainer.h create mode 100644 gpuapi/vulkan/GpuApiContainer.h create mode 100644 stdlib/PerfectHashMap.h rename {platform => system}/Library.h (88%) rename {platform => system}/SystemInfo.h (94%) create mode 100644 system/Window.h diff --git a/asset/AssetArchive.h b/asset/AssetArchive.h index ddef886..4bcd24e 100644 --- a/asset/AssetArchive.h +++ b/asset/AssetArchive.h @@ -13,7 +13,6 @@ #include "../utils/StringUtils.h" #include "../utils/EndianUtils.h" #include "../utils/Utils.h" -#include "../stdlib/simd/SIMD_I32.h" #include "../memory/RingMemory.h" #include "../memory/BufferMemory.h" #include "../image/Image.cpp" @@ -25,6 +24,12 @@ #include "../ui/UITheme.h" #include "AssetManagementSystem.h" +#if __aarch64__ + #include "../stdlib/sve/SVE_I32.h" +#else + #include "../stdlib/simd/SIMD_I32.h" +#endif + #if _WIN32 #include #include "../platform/win32/FileUtils.cpp" @@ -277,6 +282,7 @@ Asset* asset_archive_asset_load(const AssetArchive* archive, int32 id, AssetMana theme_from_data(file.content, theme); } break; default: { + UNREACHABLE(); } } } diff --git a/camera/Camera.h b/camera/Camera.h index e311e97..b08557a 100644 --- a/camera/Camera.h +++ b/camera/Camera.h @@ -144,7 +144,9 @@ void camera_movement(Camera* camera, CameraMovement* movement, f32 dt, bool rela case CAMERA_MOVEMENT_ZOOM_OUT: { camera->zoom -= velocity; } break; - default: {} + default: { + UNREACHABLE(); + } } } } else { @@ -215,7 +217,9 @@ void camera_movement(Camera* camera, CameraMovement* movement, f32 dt, bool rela case CAMERA_MOVEMENT_ZOOM_OUT: { camera->zoom -= velocity; } break; - default: {} + default: { + UNREACHABLE(); + } } } } diff --git a/font/Font.h b/font/Font.h index f1f57fa..2fe27c1 100644 --- a/font/Font.h +++ b/font/Font.h @@ -5,7 +5,12 @@ #include "../memory/BufferMemory.h" #include "../utils/EndianUtils.h" #include "../utils/Utils.h" -#include "../stdlib/simd/SIMD_I32.h" + +#if __aarch64__ + #include "../stdlib/sve/SVE_I32.h" +#else + #include "../stdlib/simd/SIMD_I32.h" +#endif #if _WIN32 #include "../platform/win32/FileUtils.cpp" diff --git a/gpuapi/RenderUtils.h b/gpuapi/RenderUtils.h index 2bdce35..22002b5 100644 --- a/gpuapi/RenderUtils.h +++ b/gpuapi/RenderUtils.h @@ -20,8 +20,8 @@ #include "../ui/UIElement.h" #include "../ui/UIAlignment.h" -// @performance Create improved vertice generation for components (input + button, chat, ...) where we don't use as many -// degenerate triangled +// @performance Create improved vertex generation for components (input + button, chat, ...) where we don't use as many +// degenerate triangle // @todo in many places we use ->value_int. We should load it as a value_float and also define it as float in the theme. // This way we wouldn't have to convert the value diff --git a/gpuapi/direct3d/GpuApiContainer.h b/gpuapi/direct3d/GpuApiContainer.h new file mode 100644 index 0000000..4d9da9d --- /dev/null +++ b/gpuapi/direct3d/GpuApiContainer.h @@ -0,0 +1,33 @@ +/** + * Jingga + * + * @copyright Jingga + * @license OMS License 2.0 + * @version 1.0.0 + * @link https://jingga.app + */ +#ifndef TOS_GPUAPI_DIRECTX_GPU_API_CONTAINER +#define TOS_GPUAPI_DIRECTX_GPU_API_CONTAINER + +#include +#include +#include +#include +#include + +struct GpuApiContainer { + Microsoft::WRL::ComPtr device; + Microsoft::WRL::ComPtr swapChain; + + Microsoft::WRL::ComPtr commandQueue; + Microsoft::WRL::ComPtr rtvHeap; + Microsoft::WRL::ComPtr renderTargets[2]; + Microsoft::WRL::ComPtr commandAllocator; + Microsoft::WRL::ComPtr commandList; + Microsoft::WRL::ComPtr pipelineState; + Microsoft::WRL::ComPtr rootSignature; + Microsoft::WRL::ComPtr fence; + UINT64 fenceValue = 0; +}; + +#endif \ No newline at end of file diff --git a/gpuapi/opengl/GpuApiContainer.h b/gpuapi/opengl/GpuApiContainer.h new file mode 100644 index 0000000..40c895d --- /dev/null +++ b/gpuapi/opengl/GpuApiContainer.h @@ -0,0 +1,15 @@ +/** + * Jingga + * + * @copyright Jingga + * @license OMS License 2.0 + * @version 1.0.0 + * @link https://jingga.app + */ +#ifndef TOS_GPUAPI_OPENGL_GPU_API_CONTAINER +#define TOS_GPUAPI_OPENGL_GPU_API_CONTAINER + +struct GpuApiContainer { +}; + +#endif \ No newline at end of file diff --git a/gpuapi/vulkan/GpuApiContainer.h b/gpuapi/vulkan/GpuApiContainer.h new file mode 100644 index 0000000..b605e7b --- /dev/null +++ b/gpuapi/vulkan/GpuApiContainer.h @@ -0,0 +1,28 @@ +/** + * Jingga + * + * @copyright Jingga + * @license OMS License 2.0 + * @version 1.0.0 + * @link https://jingga.app + */ +#ifndef TOS_GPUAPI_VULKAN_GPU_API_CONTAINER +#define TOS_GPUAPI_VULKAN_GPU_API_CONTAINER + +#include + +struct GpuApiContainer { + VkInstance instance; + VkSurfaceKHR surface; + VkDevice device; + VkSwapchainKHR swapchain; + VkPipelineLayout pipelineLayout; + VkFramebuffer framebuffer; + VkQueue graphicsQueue; + VkRenderPass renderPass; + VkPipeline pipeline; + VkCommandPool commandPool; + VkCommandBuffer commandBuffer; +}; + +#endif \ No newline at end of file diff --git a/image/Image.cpp b/image/Image.cpp index d0109b6..bd22663 100644 --- a/image/Image.cpp +++ b/image/Image.cpp @@ -87,7 +87,7 @@ int32 image_pixel_size_from_type(byte type) return 4; } break; default: { - return 0; + UNREACHABLE(); } } } diff --git a/log/Debug.cpp b/log/Debug.cpp index d59bd93..aa761ad 100644 --- a/log/Debug.cpp +++ b/log/Debug.cpp @@ -411,7 +411,9 @@ void log(const char* format, LogDataType data_type, void* data, bool should_log, case LOG_DATA_FLOAT64: { sprintf(temp, format, *((f64 *) data)); } break; - default: {} + default: { + UNREACHABLE(); + } } if (save || debug_container->log_memory.size - debug_container->log_memory.pos < MAX_LOG_LENGTH) { diff --git a/math/matrix/VectorFloat32.h b/math/matrix/VectorFloat32.h index a96363d..de15cf4 100644 --- a/math/matrix/VectorFloat32.h +++ b/math/matrix/VectorFloat32.h @@ -10,7 +10,12 @@ #define TOS_MATH_MATRIX_VECTOR_FLOAT32_H #include "../../utils/MathUtils.h" -#include "../../stdlib/simd/SIMD_F32.h" + +#if __aarch64__ + #include "../../../GameEngine/stdlib/sve/SVE_F32.h" +#else + #include "../../../GameEngine/stdlib/simd/SIMD_F32.h" +#endif struct v3_f32_4 { union { diff --git a/math/matrix/VectorFloat64.h b/math/matrix/VectorFloat64.h index ca1bdd2..83bea00 100644 --- a/math/matrix/VectorFloat64.h +++ b/math/matrix/VectorFloat64.h @@ -10,6 +10,11 @@ #define TOS_MATH_MATRIX_VECTOR_FLOAT64_H #include "../../utils/MathUtils.h" -#include "../../stdlib/simd/SIMD_F64.h" + +#if __aarch64__ + #include "../../../GameEngine/stdlib/sve/SVE_F64.h" +#else + #include "../../../GameEngine/stdlib/simd/SIMD_F64.h" +#endif #endif \ No newline at end of file diff --git a/math/matrix/VectorInt32.h b/math/matrix/VectorInt32.h index e4699de..02d73a6 100644 --- a/math/matrix/VectorInt32.h +++ b/math/matrix/VectorInt32.h @@ -13,7 +13,12 @@ #include #include "../../utils/MathUtils.h" -#include "../../stdlib/simd/SIMD_I32.h" + +#if __aarch64__ + #include "../../../GameEngine/stdlib/sve/SVE_I32.h" +#else + #include "../../../GameEngine/stdlib/simd/SIMD_I32.h" +#endif struct v3_int32_4 { union { diff --git a/math/matrix/VectorInt64.h b/math/matrix/VectorInt64.h index 2a987a7..0e25bb4 100644 --- a/math/matrix/VectorInt64.h +++ b/math/matrix/VectorInt64.h @@ -13,7 +13,12 @@ #include #include "../../utils/MathUtils.h" -#include "../../stdlib/simd/SIMD_I64.h" + +#if __aarch64__ + #include "../../../GameEngine/stdlib/sve/SVE_I64.h" +#else + #include "../../../GameEngine/stdlib/simd/SIMD_I64.h" +#endif struct v3_int64_2 { union { diff --git a/memory/Queue.h b/memory/Queue.h index 8115c6e..458bc97 100644 --- a/memory/Queue.h +++ b/memory/Queue.h @@ -14,21 +14,26 @@ typedef RingMemory Queue; +// @question Consider to add the element size into the Queue struct -> we don't need to pass it after initialization as parameter + inline void queue_alloc(Queue* queue, uint64 element_count, uint32 element_size, int32 alignment = 64) { + // @bug The alignment needs to be included in EVERY element ring_alloc(queue, element_count * element_size, alignment); } inline void queue_init(Queue* queue, BufferMemory* buf, uint64 element_count, uint32 element_size, int32 alignment = 64) { + // @bug The alignment needs to be included in EVERY element ring_init(queue, buf, element_count * element_size, alignment); } inline void queue_init(Queue* queue, byte* buf, uint64 element_count, uint32 element_size, int32 alignment = 64) { + // @bug The alignment needs to be included in EVERY element ring_init(queue, buf, element_count * element_size, alignment); } diff --git a/memory/ThreadedQueue.h b/memory/ThreadedQueue.h index b9f38f8..44c8d4d 100644 --- a/memory/ThreadedQueue.h +++ b/memory/ThreadedQueue.h @@ -48,9 +48,12 @@ struct ThreadedQueue { sem_t full; }; +// @question Consider to add the element size into the Queue struct -> we don't need to pass it after initialization as parameter + inline void thrd_queue_alloc(ThreadedQueue* queue, uint32 element_count, uint64 element_size, int32 alignment = 64) { + // @bug The alignment needs to be included in EVERY element ring_alloc((RingMemory *) queue, element_count * element_size, alignment); pthread_mutex_init(&queue->mutex, NULL); @@ -63,6 +66,7 @@ void thrd_queue_alloc(ThreadedQueue* queue, uint32 element_count, uint64 element inline void thrd_queue_init(ThreadedQueue* queue, BufferMemory* buf, uint32 element_count, uint64 element_size, int32 alignment = 64) { + // @bug The alignment needs to be included in EVERY element ring_init((RingMemory *) queue, buf, element_count * element_size, alignment); pthread_mutex_init(&queue->mutex, NULL); @@ -75,6 +79,7 @@ void thrd_queue_init(ThreadedQueue* queue, BufferMemory* buf, uint32 element_cou inline void thrd_queue_init(ThreadedQueue* queue, byte* buf, uint32 element_count, uint64 element_size, int32 alignment = 64) { + // @bug The alignment needs to be included in EVERY element ring_init((RingMemory *) queue, buf, element_count * element_size, alignment); pthread_mutex_init(&queue->mutex, NULL); diff --git a/models/settings/setting_types.h b/models/settings/setting_types.h index e0ef300..3dd399f 100644 --- a/models/settings/setting_types.h +++ b/models/settings/setting_types.h @@ -10,11 +10,6 @@ #define SETTING_TYPE_GPU_ULTRA 0x6 #define SETTING_TYPE_GPU_NEXTGEN 0x7 -#define SETTING_TYPE_GPU_API_NONE 0x0 -#define SETTING_TYPE_GPU_API_DIRECTX11 0x1 -#define SETTING_TYPE_GPU_API_DIRECTX12 0x2 -#define SETTING_TYPE_GPU_API_OPENGL 0x3 - #define SETTING_TYPE_PERSPECTIVE_FIRST 0x00 #define SETTING_TYPE_PERSPECTIVE_THIRD 0x01 #define SETTING_TYPE_PERSPECTIVE_ISOMETRIC 0x02 diff --git a/object/Mesh.h b/object/Mesh.h index 490a2b9..284d67b 100644 --- a/object/Mesh.h +++ b/object/Mesh.h @@ -19,10 +19,15 @@ #endif #include "../memory/RingMemory.h" -#include "../stdlib/simd/SIMD_I32.h" #include "../utils/EndianUtils.h" #include "../utils/StringUtils.h" +#if __aarch64__ + #include "../../../GameEngine/stdlib/sve/SVE_I32.h" +#else + #include "../../../GameEngine/stdlib/simd/SIMD_I32.h" +#endif + #define MESH_VERSION 1 // @todo how to handle different objects and groups? @@ -378,6 +383,9 @@ void mesh_from_file_txt( } text[i] = '\0'; } break; + default: { + UNREACHABLE(); + } } } diff --git a/platform/linux/SystemInfo.cpp b/platform/linux/SystemInfo.cpp index d4c78e2..55b0c2a 100644 --- a/platform/linux/SystemInfo.cpp +++ b/platform/linux/SystemInfo.cpp @@ -12,12 +12,17 @@ #include #include #include "../../stdlib/Types.h" -#include "../../stdlib/simd/SIMD_Helper.h" -#include "../SystemInfo.h" +#include "../../system/SystemInfo.h" #include #include +#if __aarch64__ + #include "../../stdlib/simd/SIMD_Helper.h" +#else + #include "../../stdlib/sve/SVE_Helper.h" +#endif + // @todo implement for arm? uint16 system_language_code() diff --git a/platform/win32/Library.h b/platform/win32/Library.h index d1ddc36..850e0b7 100644 --- a/platform/win32/Library.h +++ b/platform/win32/Library.h @@ -16,7 +16,7 @@ #include "../../stdlib/Types.h" #include "FileUtils.cpp" #include "../../utils/StringUtils.h" -#include "../Library.h" +#include "../../system/Library.h" // @todo Rename file to Library.cpp diff --git a/platform/win32/SystemInfo.cpp b/platform/win32/SystemInfo.cpp index 11e8e14..7fef158 100644 --- a/platform/win32/SystemInfo.cpp +++ b/platform/win32/SystemInfo.cpp @@ -12,8 +12,7 @@ #include #include #include "../../stdlib/Types.h" -#include "../../stdlib/simd/SIMD_Helper.h" -#include "../SystemInfo.h" +#include "../../system/SystemInfo.h" #include #include @@ -27,6 +26,12 @@ #include #include +#if __aarch64__ + #include "../../stdlib/sve/SVE_Helper.h" +#else + #include "../../stdlib/simd/SIMD_Helper.h" +#endif + // @performance Do we really need all these libs, can't we simplify that?! #include #pragma comment(lib, "Advapi32.lib") diff --git a/platform/win32/UtilsWindows.h b/platform/win32/UtilsWindows.h index 178d42a..737c1d0 100644 --- a/platform/win32/UtilsWindows.h +++ b/platform/win32/UtilsWindows.h @@ -85,12 +85,15 @@ void window_create(Window* __restrict window, void* proc) WNDPROC wndproc = (WNDPROC) proc; WNDCLASSEXA wc = {}; - HINSTANCE hinstance = GetModuleHandle(0); + + if (!window->hInstance) { + window->hInstance = GetModuleHandle(0); + } wc.cbSize = sizeof(WNDCLASSEXA); wc.style = CS_OWNDC; wc.lpfnWndProc = wndproc; - wc.hInstance = hinstance; + wc.hInstance = window->hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.lpszClassName = (LPCSTR) window->name; @@ -123,7 +126,7 @@ void window_create(Window* __restrict window, void* proc) window->x, window->y, window->width, window->height, - NULL, NULL, hinstance, window + NULL, NULL, window->hInstance, window ); ASSERT_SIMPLE(window->hwnd); diff --git a/platform/win32/Window.h b/platform/win32/Window.h index ac72443..1edfb39 100644 --- a/platform/win32/Window.h +++ b/platform/win32/Window.h @@ -11,24 +11,9 @@ #include #include "../../stdlib/Types.h" +#include "../../system/Window.h" -struct WindowState { - uint16 width; - uint16 height; - - uint16 x; - uint16 y; - uint64 style; -}; - -enum WindowStateChanges : byte { - WINDOW_STATE_CHANGE_NONE = 0, - WINDOW_STATE_CHANGE_SIZE = 1, - WINDOW_STATE_CHANGE_POS = 2, - WINDOW_STATE_CHANGE_FOCUS = 4, - WINDOW_STATE_CHANGE_FULLSCREEN = 8, - WINDOW_STATE_CHANGE_ALL = 16, -}; +typedef HINSTANCE WindowInstance; struct Window { uint16 width; @@ -48,6 +33,7 @@ struct Window { HWND hwnd; HDC hdc; HGLRC openGLRC; + HINSTANCE hInstance; char name[32]; WindowState state_old; diff --git a/platform/win32/input/RawInput.h b/platform/win32/input/RawInput.h index e0b35c9..c314baf 100644 --- a/platform/win32/input/RawInput.h +++ b/platform/win32/input/RawInput.h @@ -197,9 +197,7 @@ int rawinput_init_controllers(HWND hwnd, Input* __restrict states, RingMemory* r } } } break; - default: { - - } + default: {} } } diff --git a/stdlib/HashMap.h b/stdlib/HashMap.h index 9abcc33..e6133bc 100644 --- a/stdlib/HashMap.h +++ b/stdlib/HashMap.h @@ -72,6 +72,10 @@ struct HashMap { ChunkMemory buf; }; +// @performance Implement more like gperf, our implementation is slow. However, keep it around since it is very general purpose +// Alternatively, also create a version that creates perfect hashes (input requires a hash function and a seed for that hash function) +// Both would be saved in the hash impl. + // WARNING: element_size = element size + remaining HashEntry data size void hashmap_create(HashMap* hm, int32 count, int32 element_size, RingMemory* ring) { diff --git a/stdlib/IntrinsicsArm.h b/stdlib/IntrinsicsArm.h index 1b73689..da6c1a7 100644 --- a/stdlib/IntrinsicsArm.h +++ b/stdlib/IntrinsicsArm.h @@ -67,20 +67,4 @@ inline float oms_ceil(float a) { return svget1_f32(result); } -inline void atomic_increment(int32_t* a, int32_t b) { - __atomic_add_fetch(a, b, __ATOMIC_SEQ_CST); -} - -inline void atomic_increment(int64_t* a, int64_t b) { - __atomic_add_fetch(a, b, __ATOMIC_SEQ_CST); -} - -inline void atomic_decrement(int32_t* a, int32_t b) { - __atomic_sub_fetch(a, b, __ATOMIC_SEQ_CST); -} - -inline void atomic_decrement(int64_t* a, int64_t b) { - __atomic_sub_fetch(a, b, __ATOMIC_SEQ_CST); -} - #endif \ No newline at end of file diff --git a/stdlib/PerfectHashMap.h b/stdlib/PerfectHashMap.h new file mode 100644 index 0000000..e69de29 diff --git a/stdlib/Types.h b/stdlib/Types.h index 430ce55..461fe79 100644 --- a/stdlib/Types.h +++ b/stdlib/Types.h @@ -17,9 +17,13 @@ #define PACKED_STRUCT __pragma(pack(push, 1)) #define UNPACKED_STRUCT __pragma(pack(pop)) typedef SSIZE_T ssize_t; + + #define UNREACHABLE() __assume(0) #else #define PACKED_STRUCT __attribute__((__packed__)) #define UNPACKED_STRUCT ((void) 0) + + #define UNREACHABLE() __builtin_unreachable() #endif #define ARRAY_COUNT(a) (sizeof(a) / sizeof((a)[0])) diff --git a/platform/Library.h b/system/Library.h similarity index 88% rename from platform/Library.h rename to system/Library.h index a78f0df..48b314c 100644 --- a/platform/Library.h +++ b/system/Library.h @@ -6,8 +6,8 @@ * @version 1.0.0 * @link https://jingga.app */ -#ifndef TOS_PLATFORM_LIBRARY_H -#define TOS_PLATFORM_LIBRARY_H +#ifndef TOS_SYSTEM_LIBRARY_H +#define TOS_SYSTEM_LIBRARY_H #include "../stdlib/Types.h" diff --git a/platform/SystemInfo.h b/system/SystemInfo.h similarity index 94% rename from platform/SystemInfo.h rename to system/SystemInfo.h index 9b84fc1..1c90aab 100644 --- a/platform/SystemInfo.h +++ b/system/SystemInfo.h @@ -6,8 +6,8 @@ * @version 1.0.0 * @link https://jingga.app */ -#ifndef TOS_PLATFORM_SYSTEM_INFO_H -#define TOS_PLATFORM_SYSTEM_INFO_H +#ifndef TOS_SYSTEM_INFO_H +#define TOS_SYSTEM_INFO_H #include "../stdlib/Types.h" diff --git a/system/Window.h b/system/Window.h new file mode 100644 index 0000000..4e3c43b --- /dev/null +++ b/system/Window.h @@ -0,0 +1,32 @@ +/** + * Jingga + * + * @copyright Jingga + * @license OMS License 2.0 + * @version 1.0.0 + * @link https://jingga.app + */ +#ifndef TOS_SYSTEM_WINDOW_H +#define TOS_SYSTEM_WINDOW_H + +#include "../stdlib/Types.h" + +struct WindowState { + uint16 width; + uint16 height; + + uint16 x; + uint16 y; + uint64 style; +}; + +enum WindowStateChanges : byte { + WINDOW_STATE_CHANGE_NONE = 0, + WINDOW_STATE_CHANGE_SIZE = 1, + WINDOW_STATE_CHANGE_POS = 2, + WINDOW_STATE_CHANGE_FOCUS = 4, + WINDOW_STATE_CHANGE_FULLSCREEN = 8, + WINDOW_STATE_CHANGE_ALL = 16, +}; + +#endif \ No newline at end of file diff --git a/utils/StringUtils.h b/utils/StringUtils.h index 293b5a0..515a753 100644 --- a/utils/StringUtils.h +++ b/utils/StringUtils.h @@ -282,6 +282,42 @@ str_concat( return len_total + len; } +inline void +str_add(char* base, const char* src) +{ + while (*base) { + ++base; + } + + strcpy(base, src); +} + +inline void +str_add(char* base, const char* src, size_t src_length) +{ + while (*base) { + ++base; + } + + memcpy(base, src, src_length); + base[src_length] = '\0'; +} + +inline int64 +str_add(char* base, size_t base_length, const char* src, size_t src_length) +{ + memcpy(&base[base_length], src, src_length); + base[base_length + src_length] = '\0'; + + return base_length + src_length; +} + +inline void +str_add(char* base, size_t base_length, const char* src) +{ + strcpy(&base[base_length], src); +} + inline int64 str_concat( const char* src1, size_t src1_length,