Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gizmos_renderer.h
Go to the documentation of this file.
1#pragma once
2
3#include "gizmos/gizmos.h"
4#include <base/basetypes.hpp>
5#include <context/context.hpp>
8#include <engine/ecs/ecs.h>
9
10namespace unravel
11{
12class camera;
13class gpu_program;
15{
16public:
17 auto init(rtti::context& ctx) -> bool;
18 auto deinit(rtti::context& ctx) -> bool;
19
20 void on_frame_render(rtti::context& ctx, scene& scn, entt::handle camera_entity);
21
22private:
23 void draw_grid(uint32_t pass_id, const camera& cam, const editing_manager::grid& grid);
24 void draw_selection_gizmos(rtti::context& ctx, const camera& camera, gfx::dd_raii& dd);
25 void draw_icon_gizmos(rtti::context& ctx, scene& scn, const camera& camera, gfx::dd_raii& dd);
26 auto draw_selection_mask_pass(rtti::context& ctx, const camera& camera, const gfx::frame_buffer::ptr& selection_mask) -> bool;
27 void draw_outline_pass(const gfx::frame_buffer::ptr& selection_mask, const gfx::frame_buffer::ptr& obuffer, gfx::dd_raii& dd);
29 std::unique_ptr<gpu_program> wireframe_program_;
30 std::unique_ptr<gpu_program> grid_program_;
31
32 struct flat_to_r_program : uniforms_cache
33 {
34 void cache_uniforms()
35 {
36 }
37 std::unique_ptr<gpu_program> program;
38
39 } outline_mask_program_, outline_mask_program_skinned_;
40
41 struct outline_program : uniforms_cache
42 {
43 void cache_uniforms()
44 {
45 cache_uniform(program.get(), s_tex, "s_tex", gfx::uniform_type::Sampler);
46 cache_uniform(program.get(), u_data, "u_data", gfx::uniform_type::Vec4);
47 cache_uniform(program.get(), u_outline_color, "u_outline_color", gfx::uniform_type::Vec4);
48 }
49
52 gfx::program::uniform_ptr u_outline_color;
53
54 std::unique_ptr<gpu_program> program;
55
56 } outline_program_;
57
58 void resize_selection_mask_rt(uint16_t width, uint16_t height)
59 {
60 if(selection_mask_ && selection_mask_->get_size().width == width &&
61 selection_mask_->get_size().height == height)
62 {
63 return;
64 }
65
66 auto tex = std::make_shared<gfx::texture>(width,
67 height,
68 false, // no mip
69 1, // single layer
70 bgfx::TextureFormat::R8,
71 BGFX_TEXTURE_RT);
72
73 std::vector<gfx::texture::ptr> attachments{tex};
74 selection_mask_ = std::make_shared<gfx::frame_buffer>(attachments);
75 }
76
77 gfx::frame_buffer::ptr selection_mask_;
78
79 std::shared_ptr<int> sentinel_ = std::make_shared<int>(0);
80};
81} // namespace unravel
Class representing a camera. Contains functionality for manipulating and updating a camera....
Definition camera.h:35
auto init(rtti::context &ctx) -> bool
void on_frame_render(rtti::context &ctx, scene &scn, entt::handle camera_entity)
auto deinit(rtti::context &ctx) -> bool
std::shared_ptr< uniform > uniform_ptr
Definition program.h:19
Represents a scene in the ACE framework, managing entities and their relationships.
Definition scene.h:21
Structure for caching uniforms.
void cache_uniform(gpu_program *program, gfx::program::uniform_ptr &uniform, const hpp::string_view &name, gfx::uniform_type type, uint16_t num=1)
Caches a uniform in the GPU program.