Fix debug wireframe renderer

This commit is contained in:
2026-09-27 06:21:29 +02:00
parent a9bda25031
commit 11426fe8fb
3 changed files with 55 additions and 16 deletions

View File

@@ -84,21 +84,42 @@ void Renderer::draw_debug_wireframes(const Scene& scene, const Camera& camera,
const Rc<Shader>& debug_shader,
const Rc<Mesh>& default_mesh)
{
update_global_data(scene, camera, screen_width, screen_height);
debug_shader->bind();
debug_shader->set_mat4("u_view_projection", camera.get_view_projection_matrix(screen_width, screen_height));
set_wireframe(true);
debug_shader->bind();
for (const auto& entity : scene.get_entities()) {
// Draw all standard entities (green)
debug_shader->set_vec3("u_color", glm::vec3(0.0f, 0.7f, 0.0f));
for (const Entity& entity : scene.get_entities()) {
// If an entity has no mesh, use the default debug mesh
auto mesh = entity.mesh ? entity.mesh : default_mesh;
debug_shader->set_mat4("u_model", entity.transform.get_model_matrix());
if (entity.mesh) {
entity.mesh->draw();
} else {
default_mesh->draw();
}
mesh->draw();
}
// Draw point lights (yellow)
debug_shader->set_vec3("u_color", glm::vec3(0.7f, 0.7f, 0.0f));
for (const PointLight& light : scene.light_environment.point_lights) {
glm::mat4 model = glm::translate(glm::mat4(1.0f), light.position);
model = glm::scale(model, glm::vec3(0.2f));
debug_shader->set_mat4("u_model", model);
default_mesh->draw();
}
// Draw spot lights (cyan)
debug_shader->set_vec3("u_color", glm::vec3(0.0f, 0.7f, 0.7f));
for (const SpotLight& light : scene.light_environment.spot_lights) {
glm::mat4 model = glm::translate(glm::mat4(1.0f), light.position);
model = glm::scale(model, glm::vec3(0.2f));
debug_shader->set_mat4("u_model", model);
default_mesh->draw();
}
// Restore state
set_wireframe(false);
}