| 357 | } |
| 358 | |
| 359 | void scene_editor_app::on_draw() |
| 360 | { |
| 361 | glfwMakeContextCurrent(window); |
| 362 | |
| 363 | glEnable(GL_CULL_FACE); |
| 364 | glEnable(GL_DEPTH_TEST); |
| 365 | |
| 366 | int width, height; |
| 367 | glfwGetWindowSize(window, &width, &height); |
| 368 | |
| 369 | glViewport(0, 0, width, height); |
| 370 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
| 371 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 372 | |
| 373 | glEnable(GL_BLEND); |
| 374 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
| 375 | |
| 376 | polymer::global_debug_mesh_manager::get()->upload(); |
| 377 | polymer::global_debug_mesh_manager::get()->clear(); |
| 378 | |
| 379 | const float4x4 projectionMatrix = cam.get_projection_matrix(float(width) / float(height)); |
| 380 | const float4x4 viewMatrix = cam.get_view_matrix(); |
| 381 | const float4x4 viewProjectionMatrix = (projectionMatrix * viewMatrix); |
| 382 | |
| 383 | { |
| 384 | editorProfiler.begin("gather-scene"); |
| 385 | |
| 386 | // Clear out transient scene payload data |
| 387 | renderer_payload.reset(); |
| 388 | |
| 389 | // Lambda to assemble render component from base_object |
| 390 | auto assemble_render_component = [](base_object & obj) { |
| 391 | render_component r; |
| 392 | r.material = obj.get_component<material_component>(); |
| 393 | r.mesh = obj.get_component<mesh_component>(); |
| 394 | if (auto * xform = obj.get_component<transform_component>()) |
| 395 | { |
| 396 | r.world_matrix = xform->get_world_transform().matrix() * make_scaling_matrix(xform->local_scale); |
| 397 | } |
| 398 | r.render_sort_order = 0; |
| 399 | return r; |
| 400 | }; |
| 401 | |
| 402 | // Iterate all objects in the scene graph |
| 403 | for (auto & [e, obj] : the_scene.get_graph().graph_objects) |
| 404 | { |
| 405 | // Does the entity have a material? If so, we can render it. |
| 406 | if (auto * mat_c = obj.get_component<material_component>()) |
| 407 | { |
| 408 | auto * mesh_c = obj.get_component<mesh_component>(); |
| 409 | if (!mesh_c) continue; // for the case that we just created a material component and haven't set a mesh yet |
| 410 | |
| 411 | render_component r = assemble_render_component(obj); |
| 412 | renderer_payload.render_components.push_back(r); |
| 413 | } |
| 414 | |
| 415 | // IBL cubemap |
| 416 | if (auto * cubemap = obj.get_component<ibl_component>()) |
nothing calls this directly
no test coverage detected