Unravel Engine C++ Reference
Loading...
Searching...
No Matches
render_view.cpp
Go to the documentation of this file.
1#include "render_view.h"
2#include <cassert>
3
4namespace gfx
5{
6
7auto render_view::tex_get_or_emplace(const hpp::string_view& id) -> texture::ptr&
8{
9 auto it = textures_.find(id);
10 if(it != textures_.end())
11 {
12 return it->second;
13 }
14
15 return textures_[std::string(id)];
16}
17
18auto render_view::tex_get(const hpp::string_view& id) const -> const texture::ptr&
19{
20 const auto& tex = tex_safe_get(id);
21 assert(tex != nullptr && "Trying to get non existent element");
22 return tex;
23}
24
25
26auto render_view::tex_safe_get(const hpp::string_view& id) const -> const texture::ptr&
27{
28 auto it = textures_.find(id);
29 if(it != textures_.end())
30 {
31 return it->second;
32 }
33
34 static const texture::ptr empty;
35 return empty;
36}
37
38
39void render_view::tex_remove(const hpp::string_view& id)
40{
41 auto it = textures_.find(id);
42 if(it != textures_.end())
43 {
44 textures_.erase(it);
45 }
46}
47
48auto render_view::fbo_get_or_emplace(const hpp::string_view& id) -> frame_buffer::ptr&
49{
50 auto it = fbos_.find(id);
51 if(it != fbos_.end())
52 {
53 return it->second;
54 }
55
56 return fbos_[std::string(id)];
57}
58
59auto render_view::fbo_get(const hpp::string_view& id) const -> const frame_buffer::ptr&
60{
61 const auto& fbo = fbo_safe_get(id);
62 assert(fbo != nullptr && "Trying to get non existent element");
63 return fbo;
64}
65
66auto render_view::fbo_safe_get(const hpp::string_view& id) const -> const frame_buffer::ptr&
67{
68 auto it = fbos_.find(id);
69 if(it != fbos_.end())
70 {
71 return it->second;
72 }
73
74 static const frame_buffer::ptr empty;
75 return empty;
76}
77
78void render_view::fbo_remove(const hpp::string_view& id)
79{
80 auto it = fbos_.find(id);
81 if(it != fbos_.end())
82 {
83 fbos_.erase(it);
84 }
85}
86
87auto render_view::data_get_or_emplace(const hpp::string_view& id, uint32_t default_val) -> uint32_t&
88{
89 auto it = data_.find(id);
90 if(it != data_.end())
91 {
92 return it->second;
93 }
94
95 return data_.emplace(std::string(id), default_val).first->second;
96}
97
98auto render_view::data_get(const hpp::string_view& id, uint32_t default_val) const -> uint32_t
99{
100 auto it = data_.find(id);
101 if(it != data_.end())
102 {
103 return it->second;
104 }
105
106 return default_val;
107}
108
109} // namespace gfx
auto fbo_safe_get(const hpp::string_view &id) const -> const frame_buffer::ptr &
void tex_remove(const hpp::string_view &id)
auto data_get(const hpp::string_view &id, uint32_t default_val=0) const -> uint32_t
auto fbo_get_or_emplace(const hpp::string_view &id) -> frame_buffer::ptr &
auto fbo_get(const hpp::string_view &id) const -> const frame_buffer::ptr &
auto tex_get(const hpp::string_view &id) const -> const texture::ptr &
auto tex_safe_get(const hpp::string_view &id) const -> const texture::ptr &
void fbo_remove(const hpp::string_view &id)
auto tex_get_or_emplace(const hpp::string_view &id) -> texture::ptr &
auto data_get_or_emplace(const hpp::string_view &id, uint32_t default_val=0) -> uint32_t &