diff options
-rw-r--r-- | examples/obj_loading/ex_obj_loading.c | 2 | ||||
-rw-r--r-- | src/renderer/render.c | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/examples/obj_loading/ex_obj_loading.c b/examples/obj_loading/ex_obj_loading.c index e225cb2..aaed2a0 100644 --- a/examples/obj_loading/ex_obj_loading.c +++ b/examples/obj_loading/ex_obj_loading.c @@ -1,3 +1,4 @@ +#include <assert.h> #include <glfw3.h> #include <string.h> @@ -25,6 +26,7 @@ int main() { model_handle backpack_handle = model_load_obj(core, "assets/models/obj/backpack/backpack.obj", true); model* backpack = &core->models->data[backpack_handle.raw]; + assert(backpack->meshes->data->is_skinned == false); // 2. upload vertex data to gpu model_upload_meshes(&core->renderer, backpack); // 3. create a camera diff --git a/src/renderer/render.c b/src/renderer/render.c index 83011f8..b688613 100644 --- a/src/renderer/render.c +++ b/src/renderer/render.c @@ -176,14 +176,9 @@ void draw_mesh(renderer* ren, mesh* mesh, mat4* model_tf, material* mat, mat4* v bind_texture(lighting_shader, &mat->specular_texture, 1); // bind to slot 1 uniform_f32(lighting_shader.program_id, "material.shininess", 32.); - // upload model transform - // mat4 trans = mat4_translation(tf.position); - // mat4 rot = mat4_rotation(tf.rotation); - // mat4 scale = mat4_scale(tf.scale); - // mat4 model_tf = mat4_mult(trans, mat4_mult(rot, scale)); + // upload model, view, and projection matrices uniform_mat4f(lighting_shader.program_id, "model", model_tf); - // upload view & projection matrices uniform_mat4f(lighting_shader.program_id, "view", view); uniform_mat4f(lighting_shader.program_id, "projection", proj); @@ -333,7 +328,7 @@ void model_upload_meshes(renderer* ren, model* model) { size_t skinned_vertex_size = 2 * sizeof(vec3) + sizeof(vec2) + 4 * sizeof(u32) + sizeof(vec4); size_t vertex_size = mesh.is_skinned ? skinned_vertex_size : static_vertex_size; - TRACE("sizeof(vertex) -> %ld, vertex_size -> %ld\n", sizeof(vertex), vertex_size); + // TRACE("sizeof(vertex) -> %ld, vertex_size -> %ld\n", sizeof(vertex), vertex_size); if (mesh.is_skinned) { assert(vertex_size == (12 + 12 + 8 + 16 + 16)); } else { @@ -345,10 +340,9 @@ void model_upload_meshes(renderer* ren, model* model) { for (int i = 0; i < num_vertices; i++) { u8* p = bytes + vertex_size * i; - u8* bone_data_offset = p + static_vertex_size; - memcpy(p, &mesh.vertices->data[i], sizeof(vertex)); + memcpy(p, &mesh.vertices->data[i], static_vertex_size); if (mesh.is_skinned) { - // printf("") + u8* bone_data_offset = p + static_vertex_size; memcpy(bone_data_offset, &mesh.vertex_bone_data->data[i], sizeof(vertex_bone_data)); } } |