sandbox
Loading...
Searching...
No Matches
grid_subrenderer.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCENES_GRID_SUBRENDERER_HPP_
3#define LIBSBX_SCENES_GRID_SUBRENDERER_HPP_
4
5#include <libsbx/math/vector4.hpp>
7
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>
13
14namespace sbx::scenes {
15
17
18 inline static const auto pipeline_definition = sbx::graphics::pipeline_definition{
19 .depth = sbx::graphics::depth::read_only,
20 .uses_transparency = true,
21 .rasterization_state = sbx::graphics::rasterization_state{
22 .polygon_mode = sbx::graphics::polygon_mode::fill,
23 .cull_mode = sbx::graphics::cull_mode::none,
24 .front_face = sbx::graphics::front_face::counter_clockwise
25 }
26 };
27
28 inline static constexpr auto default_shader_path = std::string_view{"engine://shaders/grid"};
29
30public:
31
32 grid_subrenderer(const std::vector<graphics::attachment_description>& attachments, const std::filesystem::path& path = default_shader_path)
34 _pipeline{path, attachments, pipeline_definition},
35 _push_handler{_pipeline},
36 _descriptor_handler{_pipeline, 0u} { }
37
38 ~grid_subrenderer() override {
39
40 }
41
42 auto render(sbx::graphics::command_buffer& command_buffer) -> void override {
43 EASY_BLOCK("grid_subrenderer::render");
44
45 auto& scenes_module = sbx::core::engine::get_module<sbx::scenes::scenes_module>();
46 auto& scene = scenes_module.active_scene();
47 auto& environment = scene.environment();
48 auto& graph = scene.graph();
49
50 _pipeline.bind(command_buffer);
51
52 _push_handler.push("origin", sbx::math::vector4::zero);
53
54 _descriptor_handler.push("scene", environment.uniform_handler());
55
56 if (!_descriptor_handler.update(_pipeline)) {
57 return;
58 }
59
60 _descriptor_handler.bind_descriptors(command_buffer);
61 _push_handler.bind(command_buffer);
62
63 command_buffer.draw(6u, 1u, 0u, 0u);
64 }
65
66private:
67
69
70 sbx::graphics::push_handler _push_handler;
71
72 sbx::graphics::descriptor_handler _descriptor_handler;
73
74}; // class debug_subrenderer
75
76} // namespace sbx::scenes
77
78#endif // LIBSBX_SCENES_GRID_SUBRENDERER_HPP_
Definition: command_buffer.hpp:15
Definition: descriptor_handler.hpp:26
Definition: graphics_pipeline.hpp:115
Definition: push_handler.hpp:18
Definition: subrenderer.hpp:14
Definition: grid_subrenderer.hpp:16
Definition: scene.hpp:27
Definition: scenes_module.hpp:26
RGBA color representation and utilities.
Definition: graphics_pipeline.hpp:106
Definition: graphics_pipeline.hpp:67