summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-18 17:54:31 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-18 17:54:31 +1100
commit28bd234a45995b62544e6b5f70d40dfe39ef2e99 (patch)
tree1aca5cd820091e6b9652ee7d104b9b337343e0fb
parent68f590c848e0e91d70e7116655464f392ed6df46 (diff)
recompile .o files when header changes
-rw-r--r--Makefile2
-rw-r--r--TODO.md2
-rw-r--r--include/celeritas.h4
-rw-r--r--src/core.c17
-rw-r--r--src/debug_strings.c5
-rw-r--r--src/maths.c8
6 files changed, 29 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 0c88a03..597ecdc 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ endif
# $^ - prerequisites of current rule separated by spaces
# $< - first prerequisite file only
-$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c include/celeritas.h
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@
diff --git a/TODO.md b/TODO.md
index 00fb831..c4aac15 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,7 +6,7 @@
- compile example
- [x] Consolidate down to a handful of examples
- [x] Get rid of doxygen
-- [ ] make format
+- [x] make format
- [ ] Move to Vulkan-first rendering
- [ ] Build in CI pipeline (needs vulkan)
- [ ] Incorporate vma \ No newline at end of file
diff --git a/include/celeritas.h b/include/celeritas.h
index 534fb85..0b56bf5 100644
--- a/include/celeritas.h
+++ b/include/celeritas.h
@@ -563,7 +563,7 @@ model_handle model_load_from_gltf(const char* path);
typedef enum keyframe_kind { Keyframe_Rotation, Keyframe_Translation, Keyframe_Scale, Keyframe_Weights } keyframe_kind;
-const char* keyframe_kind_strings[4] = { "ROTATION", "TRANSLATION", "SCALE", "WEIGHTS" };
+extern const char* keyframe_kind_strings[4];
typedef union keyframe {
quat rotation;
@@ -580,6 +580,8 @@ typedef struct keyframes {
typedef enum interpolation { Interpolation_Step, Interpolation_Linear, Interpolation_Cubic } interpolation;
+extern const char* interpolation_strings[3];
+
typedef struct animation_spline {
f32* timestamps;
size_t n_timestamps;
diff --git a/src/core.c b/src/core.c
index 0cbaa09..e1ffeab 100644
--- a/src/core.c
+++ b/src/core.c
@@ -27,16 +27,21 @@ void core_bringup(const char* window_name, struct GLFWwindow* optional_window) {
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
char* full_window_name = malloc(sizeof(char) * 100);
- int _offset = sprintf(full_window_name, "%s (%s)", window_name, gapi);
+ sprintf(full_window_name, "%s (%s)", window_name, gapi);
+
+ if (optional_window) {
+ g_core.window = optional_window;
+ } else {
+ GLFWwindow* glfw_window = glfwCreateWindow(800, 600, full_window_name, NULL, NULL);
+ g_core.window = glfw_window;
+ }
- GLFWwindow* glfw_window = glfwCreateWindow(800, 600, full_window_name, NULL, NULL);
- g_core.window = glfw_window;
// This may move into a renderer struct
- ral_backend_init(window_name, glfw_window);
+ ral_backend_init(window_name, g_core.window);
- glfwSetKeyCallback(glfw_window, key_callback);
- glfwSetFramebufferSizeCallback(glfw_window, resize_callback);
+ glfwSetKeyCallback(g_core.window, key_callback);
+ glfwSetFramebufferSizeCallback(g_core.window, resize_callback);
}
void core_shutdown() {
ral_backend_shutdown();
diff --git a/src/debug_strings.c b/src/debug_strings.c
new file mode 100644
index 0000000..b1e09aa
--- /dev/null
+++ b/src/debug_strings.c
@@ -0,0 +1,5 @@
+#include <celeritas.h>
+
+const char* keyframe_kind_strings[4] = { "ROTATION", "TRANSLATION", "SCALE", "WEIGHTS" };
+
+const char* interpolation_strings[3] = { "Step", "Linear", "Cubic" }; \ No newline at end of file
diff --git a/src/maths.c b/src/maths.c
index fbfcd72..10fa9e0 100644
--- a/src/maths.c
+++ b/src/maths.c
@@ -2,6 +2,10 @@
vec3 vec3_create(f32 x, f32 y, f32 z) { return (vec3){ x, y, z }; }
+vec3 vec3_add(vec3 u, vec3 v) {
+ return (vec3){ .x = u.x + v.x, .y = u.y + v.y, .z = u.z + v.z };
+}
+
vec4 vec4_create(f32 x, f32 y, f32 z, f32 w) { return (vec4){ x, y, z, w }; }
mat4 mat4_ident() { return (mat4){ .data = { 1.0, 0., 0., 0., 0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0., 1.0 } }; }
@@ -35,3 +39,7 @@ mat4 mat4_perspective(f32 fov_radians, f32 aspect_ratio, f32 near_z, f32 far_z)
out_matrix.data[14] = -((2.0f * far_z * near_z) / (far_z - near_z));
return out_matrix;
}
+
+mat4 mat4_look_at(vec3 position, vec3 target, vec3 up) {
+ // TODO
+} \ No newline at end of file