idk whats going on here

This commit is contained in:
2025-10-17 16:20:30 +01:00
parent a03c7c85b8
commit 49d1fb80ab
2 changed files with 9 additions and 2 deletions

View File

@@ -28,7 +28,14 @@ Obj load_obj(const std::string& filename) {
sscanf(line.c_str() + 2, "%f %f %f", &obj.vertices[(obj.vertex_count - 1) * 3], &obj.vertices[(obj.vertex_count - 1) * 3 + 1], &obj.vertices[(obj.vertex_count - 1) * 3 + 2]); sscanf(line.c_str() + 2, "%f %f %f", &obj.vertices[(obj.vertex_count - 1) * 3], &obj.vertices[(obj.vertex_count - 1) * 3 + 1], &obj.vertices[(obj.vertex_count - 1) * 3 + 2]);
} else if (line.substr(0, 2) == "f ") { } else if (line.substr(0, 2) == "f ") {
// Face indices // Face indices
unsigned int index1, // f 2/1 3/2 1/3
unsigned int index1, texture1, index2, texture2, index3, texture3;
sscanf(line.c_str() + 2, "%u/%u %u/%u %u/%u", &index1, &texture1, &index2, &texture2, &index3, &texture3);
obj.index_count += 3;
obj.indices = (unsigned int*)realloc(obj.indices, obj.index_count * sizeof(unsigned int));
obj.indices[obj.index_count - 3] = index1 - 1; // OBJ indices are 1-based
obj.indices[obj.index_count - 2] = index2 - 1;
obj.indices[obj.index_count - 1] = index3 - 1;
} else if (line.substr(0, 2) == "vn") { } else if (line.substr(0, 2) == "vn") {
// Vertex normal // Vertex normal
obj.normal_count++; obj.normal_count++;

View File

@@ -132,7 +132,7 @@ int main(int argc, char* argv[]) {
init(); init();
// Load shader program // Load shader program
Shader shader_program("shaders/triangle_untextured.vert", "shaders/triangle_untextured.frag"); Shader shader_program("shaders/triangle.vert", "shaders/triangle.frag");
// Generate and set up textures // Generate and set up textures
Texture texture1("assets/crate.jpg"); Texture texture1("assets/crate.jpg");