summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/log.h5
-rw-r--r--src/maths/primitives.c37
-rw-r--r--src/maths/primitives.h1
-rw-r--r--src/render/pbr.c16
-rw-r--r--src/resources/gltf.c2
5 files changed, 52 insertions, 9 deletions
diff --git a/src/log.h b/src/log.h
index 0ece7e6..537cb6e 100644
--- a/src/log.h
+++ b/src/log.h
@@ -10,6 +10,11 @@
exit(1); \
}
+#define TODO(msg) \
+ do { \
+ ERROR_EXIT("TODO: %s", msg); \
+ } while (0)
+
#define LOG_WARN_ENABLED 1
#define LOG_INFO_ENABLED 1
diff --git a/src/maths/primitives.c b/src/maths/primitives.c
index 05c31ca..3387084 100644
--- a/src/maths/primitives.c
+++ b/src/maths/primitives.c
@@ -2,6 +2,7 @@
#include "colours.h"
#include "log.h"
#include "maths.h"
+#include "maths_types.h"
#include "ral_types.h"
#include "render_types.h"
@@ -232,3 +233,39 @@ Geometry Geo_CreateUVsphere(f32 radius, u32 north_south_lines, u32 east_west_lin
return geo;
}
+
+Geometry Geo_CreateCylinder(f32 radius, f32 height, u32 resolution) {
+ TODO("implement cylinder meshing");
+}
+
+Geometry Geo_CreateCone(f32 radius, f32 height, u32 resolution) {
+ Vertex_darray* vertices = Vertex_darray_new(1);
+ u32_darray* indices = u32_darray_new(1);
+
+ // tip
+ VERT_3D(vertices, vec3(0.0, height, 0.0), VEC3_Y, vec2(0, 0)); // TODO: fix uvs
+
+ // base center
+ VERT_3D(vertices, VEC3_ZERO, VEC3_NEG_Y, vec2(0, 0)); // TODO: fix uvs
+
+ // base circle
+ f32 step = TAU / resolution;
+ for (u32 i = 0; i < resolution; i++) {
+ f32 x = cos(step * i) * radius;
+ f32 z = sin(step * i) * radius;
+ VERT_3D(vertices, vec3(x, 0.0, z), VEC3_NEG_Z, vec2(0, 0));
+ }
+
+ // sides
+ for (u32 i = 0; i < resolution; i++) {
+ }
+
+ Geometry geo = {
+ .format = VERTEX_STATIC_3D,
+ .vertices = vertices,
+ .has_indices = true,
+ .index_count = indices->len,
+ .indices = indices,
+ };
+ return geo;
+} \ No newline at end of file
diff --git a/src/maths/primitives.h b/src/maths/primitives.h
index bcf71c8..4965545 100644
--- a/src/maths/primitives.h
+++ b/src/maths/primitives.h
@@ -9,6 +9,7 @@
Geometry Geo_CreatePlane(f32x2 extents, u32 tiling_u, u32 tiling_v);
Geometry Geo_CreateCuboid(f32x3 extents);
Geometry Geo_CreateCylinder(f32 radius, f32 height, u32 resolution);
+Geometry Geo_CreateCone(f32 radius, f32 height, u32 resolution);
Geometry Geo_CreateUVsphere(f32 radius, u32 north_south_lines, u32 east_west_lines);
Geometry Geo_CreateIcosphere(f32 radius, f32 n_subdivisions);
diff --git a/src/render/pbr.c b/src/render/pbr.c
index cfa02fc..044e6eb 100644
--- a/src/render/pbr.c
+++ b/src/render/pbr.c
@@ -25,11 +25,11 @@ GPU_Renderpass* PBR_RPassCreate() {
}
void PBR_PipelinesCreate(PBR_Storage* storage, GPU_Renderpass* rpass) {
- // Common shader bindings
- ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL);
- ShaderDataLayout model_data = Binding_Model_GetLayout(NULL);
- ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL);
- ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL);
+ // Common shader bindings
+ ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL);
+ ShaderDataLayout model_data = Binding_Model_GetLayout(NULL);
+ ShaderDataLayout material_data = PBRMaterial_GetLayout(NULL);
+ ShaderDataLayout lights_data = Binding_Lights_GetLayout(NULL);
// Static
{
@@ -144,9 +144,9 @@ void PBR_Execute(PBR_Storage* storage, Camera camera, TextureHandle shadowmap_te
Binding_Model model_data = { .model = renderable.affine };
GPU_EncodeBindShaderData(enc, 1, Binding_Model_GetLayout(&model_data));
- AnimDataUniform anim_data = {0};
- for (int i =0; i < 4; i++) {
- anim_data.bone_matrices[i] = mat4_ident();
+ AnimDataUniform anim_data = { 0 };
+ for (int i = 0; i < 4; i++) {
+ anim_data.bone_matrices[i] = mat4_ident();
}
GPU_EncodeBindShaderData(enc, 3, AnimData_GetLayout(&anim_data));
// Calculate matrices here
diff --git a/src/resources/gltf.c b/src/resources/gltf.c
index c5f1fd1..76ba0a5 100644
--- a/src/resources/gltf.c
+++ b/src/resources/gltf.c
@@ -168,7 +168,7 @@ bool model_load_gltf_str(const char* file_string, const char* filepath, Str8 rel
// --- Skin
size_t num_skins = data->skins_count;
bool is_skinned = false;
- Armature main_skeleton = {0};
+ Armature main_skeleton = { 0 };
if (num_skins == 1) {
is_skinned = true;
} else if (num_skins > 1) {