2#ifndef LIBSBX_SCENES_GRID_SUBRENDERER_HPP_
3#define LIBSBX_SCENES_GRID_SUBRENDERER_HPP_
5#include <libsbx/math/vector4.hpp>
8#include <libsbx/graphics/subrenderer.hpp>
9#include <libsbx/graphics/pipeline/graphics_pipeline.hpp>
10#include <libsbx/graphics/buffers/push_handler.hpp>
11#include <libsbx/graphics/buffers/storage_handler.hpp>
12#include <libsbx/graphics/descriptor/descriptor_handler.hpp>
14namespace sbx::scenes {
21 .depth = sbx::graphics::depth::read_only,
22 .uses_transparency =
true,
24 .polygon_mode = sbx::graphics::polygon_mode::fill,
25 .cull_mode = sbx::graphics::cull_mode::none,
26 .front_face = sbx::graphics::front_face::counter_clockwise
34 pipeline(
const std::filesystem::path& path,
const std::vector<graphics::attachment_description>& attachments)
35 : base_type{path, attachments, pipeline_definition} { }
37 ~pipeline()
override =
default;
43 grid_subrenderer(
const std::vector<graphics::attachment_description>& attachments,
const std::filesystem::path& path)
45 _pipeline{path, attachments},
46 _push_handler{_pipeline},
47 _descriptor_handler{_pipeline, 0u} { }
54 auto&
scenes_module = sbx::core::engine::get_module<sbx::scenes::scenes_module>();
57 auto camera_node =
scene.camera();
61 const auto& projection =
camera.projection();
63 const auto camera_position =
scene.world_position(camera_node);
65 const auto view = sbx::math::matrix4x4::inverted(
scene.world_transform(camera_node));
67 _pipeline.bind(command_buffer);
69 _push_handler.push(
"mvp", projection * view);
70 _push_handler.push(
"camera_position", camera_position);
71 _push_handler.push(
"origin", sbx::math::vector4::zero);
75 if (!_descriptor_handler.update(_pipeline)) {
79 _descriptor_handler.bind_descriptors(command_buffer);
80 _push_handler.bind(command_buffer);
82 command_buffer.draw(6u, 1u, 0u, 0u);
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: graphics_pipeline.hpp:113
Definition: push_handler.hpp:18
Definition: subrenderer.hpp:14
Definition: camera.hpp:96
Definition: grid_subrenderer.hpp:16
Definition: scenes_module.hpp:21
RGBA color representation and utilities.
Definition: graphics_pipeline.hpp:104
Definition: graphics_pipeline.hpp:65