diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/rune/graphics.h | 38 | ||||
-rw-r--r-- | include/rune/list.h | 53 | ||||
-rw-r--r-- | include/rune/logging.h | 37 | ||||
-rw-r--r-- | include/rune/types.h | 40 | ||||
-rw-r--r-- | include/rune/util.h | 54 | ||||
-rw-r--r-- | include/rune_list.h | 32 | ||||
-rw-r--r-- | include/rune_logging.h | 16 | ||||
-rw-r--r-- | include/rune_math.h | 37 | ||||
-rw-r--r-- | include/rune_types.h | 40 | ||||
-rw-r--r-- | include/rune_util.h | 11 |
10 files changed, 222 insertions, 136 deletions
diff --git a/include/rune/graphics.h b/include/rune/graphics.h new file mode 100644 index 0000000..8f10b4a --- /dev/null +++ b/include/rune/graphics.h @@ -0,0 +1,38 @@ +/* + * Rune Game Engine + * Copyright 2024 Danny Holman <dholman@gymli.org> + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef RUNE_GRAPHICS_H +#define RUNE_GRAPHICS_H + +#include <rune/types.h> +#include <GLFW/glfw3.h> + +struct rune_window { + uint32_t winw; + uint32_t winh; + const char *wintitle; + GLFWwindow *window; +}; + +RAPI int rune_gfx_init(struct rune_window *window); +RAPI void rune_gfx_quit(struct rune_window *window); + +#endif diff --git a/include/rune/list.h b/include/rune/list.h new file mode 100644 index 0000000..1107491 --- /dev/null +++ b/include/rune/list.h @@ -0,0 +1,53 @@ +/* + * Rune Game Engine + * Copyright 2024 Danny Holman <dholman@gymli.org> + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef RUNE_LIST_H +#define RUNE_LIST_H + +#include <stddef.h> + +struct list_head { + struct list_head *next; + struct list_head *prev; +}; + +static inline void list_add(struct list_head *new, struct list_head *head) { + struct list_head *temp = head; + while (temp->next != NULL) + temp = temp->next; + + temp->next = new; + new->prev = temp; + new->next = NULL; +} + +static inline void list_del(struct list_head *item) { + struct list_head *next = item->next; + struct list_head *prev = item->prev; + if (next != NULL) + next->prev = prev; + if (prev != NULL) + prev->next = next; + item->next = NULL; + item->prev = NULL; +} + +#endif diff --git a/include/rune/logging.h b/include/rune/logging.h new file mode 100644 index 0000000..5b9aabf --- /dev/null +++ b/include/rune/logging.h @@ -0,0 +1,37 @@ +/* + * Rune Game Engine + * Copyright 2024 Danny Holman <dholman@gymli.org> + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef RUNE_LOGGING_H +#define RUNE_LOGGING_H + +#include <rune/util.h> + +enum log_level { + LOG_FATAL, + LOG_ERROR, + LOG_WARN, + LOG_INFO, + LOG_DEBUG +}; + +RAPI void log_output(int level, const char *fmt, ...); + +#endif diff --git a/include/rune/types.h b/include/rune/types.h new file mode 100644 index 0000000..03e3edb --- /dev/null +++ b/include/rune/types.h @@ -0,0 +1,40 @@ +/* + * Rune Game Engine + * Copyright 2024 Danny Holman <dholman@gymli.org> + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef RUNE_TYPES_H +#define RUNE_TYPES_H + +#include <rune/util.h> + +STATIC_ASSERT(sizeof(uint8_t) == 1, "Expected uint8_t to be 1 byte"); +STATIC_ASSERT(sizeof(uint16_t) == 2, "Expected uint16_t to be 2 bytes"); +STATIC_ASSERT(sizeof(uint32_t) == 4, "Expected uint32_t to be 4 bytes"); +STATIC_ASSERT(sizeof(uint64_t) == 8, "Expected uint64_t to be 8 bytes"); + +STATIC_ASSERT(sizeof(int8_t) == 1, "Expected int8_t to be 1 byte"); +STATIC_ASSERT(sizeof(int16_t) == 2, "Expected int16_t to be 2 bytes"); +STATIC_ASSERT(sizeof(int32_t) == 4, "Expected int32_t to be 4 bytes"); +STATIC_ASSERT(sizeof(int64_t) == 8, "Expected int64_t to be 8 bytes"); + +STATIC_ASSERT(sizeof(float) == 4, "Expected float to be 4 bytes"); +STATIC_ASSERT(sizeof(double) == 8, "Expected double to be 8 bytes"); + +#endif diff --git a/include/rune/util.h b/include/rune/util.h new file mode 100644 index 0000000..04429c4 --- /dev/null +++ b/include/rune/util.h @@ -0,0 +1,54 @@ +/* + * Rune Game Engine + * Copyright 2024 Danny Holman <dholman@gymli.org> + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef RUNE_UTIL_H +#define RUNE_UTIL_H + +#include <assert.h> +#include <stdint.h> + +#if defined(__clang__) || defined(__gcc__) + #define STATIC_ASSERT _Static_assert +#else + #define STATIC_ASSERT static_assert +#endif + + +#ifdef REXPORT + #ifdef _MSC_VER + #define RAPI __declspec(dllexport) + #else + #define RAPI __attribute__((visibility("default"))) + #endif +#else + #ifdef _MSC_VER + #define RAPI __declspec(dllexport) + #else + #define RAPI + #endif +#endif + +static inline uint32_t clamp(uint32_t value, float min, float max) { + const uint32_t ret = value < min ? min : value; + return ret > max ? max : ret; +} + +#endif diff --git a/include/rune_list.h b/include/rune_list.h deleted file mode 100644 index 9c7c651..0000000 --- a/include/rune_list.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef RUNE_LIST_H -#define RUNE_LIST_H - -#include <stddef.h> - -struct list_head { - struct list_head *next; - struct list_head *prev; -}; - -static inline void list_add(struct list_head *new, struct list_head *head) { - struct list_head *temp = head; - while (temp->next != NULL) - temp = temp->next; - - temp->next = new; - new->prev = temp; - new->next = NULL; -} - -static inline void list_del(struct list_head *item) { - struct list_head *next = item->next; - struct list_head *prev = item->prev; - if (next != NULL) - next->prev = prev; - if (prev != NULL) - prev->next = next; - item->next = NULL; - item->prev = NULL; -} - -#endif diff --git a/include/rune_logging.h b/include/rune_logging.h deleted file mode 100644 index f8876db..0000000 --- a/include/rune_logging.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef RUNE_LOGGING_H -#define RUNE_LOGGING_H - -#include <rune_types.h> - -enum log_level { - LOG_FATAL, - LOG_ERROR, - LOG_WARN, - LOG_INFO, - LOG_DEBUG -}; - -RAPI void log_output(int level, const char *fmt, ...); - -#endif diff --git a/include/rune_math.h b/include/rune_math.h deleted file mode 100644 index 25bf4fd..0000000 --- a/include/rune_math.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef RUNE_MATH_H -#define RUNE_MATH_H - -struct vec2 { - float x; - float y; -}; - -struct vec3 { - float x; - float y; - float z; -}; - -struct vec4 { - float x; - float y; - float z; - float w; -}; - -struct mat3 { - struct vec3 v[3]; -}; - -struct mat4 { - struct vec3 v[4]; -}; - -struct quat { - float x; - float y; - float z; - float w; -}; - -#endif diff --git a/include/rune_types.h b/include/rune_types.h deleted file mode 100644 index 8fada14..0000000 --- a/include/rune_types.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef RUNE_TYPES_H -#define RUNE_TYPES_H - -#include <assert.h> -#include <stdint.h> - -#if defined(__clang__) || defined(__gcc__) - #define STATIC_ASSERT _Static_assert -#else - #define STATIC_ASSERT static_assert -#endif - -STATIC_ASSERT(sizeof(uint8_t) == 1, "Expected uint8_t to be 1 byte"); -STATIC_ASSERT(sizeof(uint16_t) == 2, "Expected uint16_t to be 2 bytes"); -STATIC_ASSERT(sizeof(uint32_t) == 4, "Expected uint32_t to be 4 bytes"); -STATIC_ASSERT(sizeof(uint64_t) == 8, "Expected uint64_t to be 8 bytes"); - -STATIC_ASSERT(sizeof(int8_t) == 1, "Expected int8_t to be 1 byte"); -STATIC_ASSERT(sizeof(int16_t) == 2, "Expected int16_t to be 2 bytes"); -STATIC_ASSERT(sizeof(int32_t) == 4, "Expected int32_t to be 4 bytes"); -STATIC_ASSERT(sizeof(int64_t) == 8, "Expected int64_t to be 8 bytes"); - -STATIC_ASSERT(sizeof(float) == 4, "Expected float to be 4 bytes"); -STATIC_ASSERT(sizeof(double) == 8, "Expected double to be 8 bytes"); - -#ifdef REXPORT - #ifdef _MSC_VER - #define RAPI __declspec(dllexport) - #else - #define RAPI __attribute__((visibility("default"))) - #endif -#else - #ifdef _MSC_VER - #define RAPI __declspec(dllexport) - #else - #define RAPI - #endif -#endif - -#endif diff --git a/include/rune_util.h b/include/rune_util.h deleted file mode 100644 index f0613c9..0000000 --- a/include/rune_util.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef RUNE_UTIL_H -#define RUNE_UTIL_H - -#include <stdint.h> - -static inline uint32_t clamp(uint32_t value, float min, float max) { - const uint32_t ret = value < min ? min : value; - return ret > max ? max : ret; -} - -#endif |