Unravel Engine C++ Reference
Loading...
Searching...
No Matches
frame_buffer.h
Go to the documentation of this file.
1#pragma once
2
3#include "graphics.h"
4#include "texture.h"
5#include <memory>
6#include <vector>
7
8namespace gfx
9{
11{
13 std::shared_ptr<gfx::texture> texture;
15 std::uint16_t mip = 0;
17 std::uint16_t layer = 0;
18
19 bool generate_mips{true};
20};
21
22struct frame_buffer : public handle_impl<frame_buffer, frame_buffer_handle>
23{
24 //-----------------------------------------------------------------------------
25 // Name : frame_buffer ()
31 //-----------------------------------------------------------------------------
32 frame_buffer() = default;
33 //-----------------------------------------------------------------------------
34 // Name : frame_buffer ()
40 //-----------------------------------------------------------------------------
41 frame_buffer(std::uint16_t _width,
42 std::uint16_t _height,
43 texture_format _format,
44 std::uint32_t _texture_flags = BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP);
45
46 //-----------------------------------------------------------------------------
47 // Name : frame_buffer ()
53 //-----------------------------------------------------------------------------
54 frame_buffer(const std::vector<texture::ptr>& textures);
55
56 //-----------------------------------------------------------------------------
57 // Name : frame_buffer ()
63 //-----------------------------------------------------------------------------
64 frame_buffer(const std::vector<fbo_attachment>& textures);
65
66 //-----------------------------------------------------------------------------
67 // Name : frame_buffer ()
73 //-----------------------------------------------------------------------------
74 frame_buffer(void* _nwh,
75 std::uint16_t _width,
76 std::uint16_t _height,
77 texture_format _format = texture_format::Count,
78 texture_format _depth_format = texture_format::Count);
79
80 //-----------------------------------------------------------------------------
81 // Name : populate ()
87 //-----------------------------------------------------------------------------
88 void populate(const std::vector<texture::ptr>& textures);
89 void populate(const std::vector<fbo_attachment>& textures);
90
91 //-----------------------------------------------------------------------------
92 // Name : get_size ()
98 //-----------------------------------------------------------------------------
99 [[nodiscard]] auto get_size() const -> usize32_t;
100
101 //-----------------------------------------------------------------------------
102 // Name : get_attachment ()
108 //-----------------------------------------------------------------------------
109 [[nodiscard]] auto get_attachment(std::uint32_t index = 0) const -> const fbo_attachment&;
110 [[nodiscard]] auto get_attachments() const -> const std::vector<fbo_attachment>&;
111 //-----------------------------------------------------------------------------
112 // Name : get_attachment ()
118 //-----------------------------------------------------------------------------
119 [[nodiscard]] auto get_texture(std::uint32_t index = 0) const -> const gfx::texture::ptr&;
120
121 //-----------------------------------------------------------------------------
122 // Name : get_attachment_count ()
128 //-----------------------------------------------------------------------------
129 [[nodiscard]] auto get_attachment_count() const -> size_t;
130
131private:
133 usize32_t cached_size_ = {0, 0};
135 std::vector<fbo_attachment> textures_;
136};
137} // namespace gfx
bgfx::TextureFormat::Enum texture_format
Definition format.h:10
std::shared_ptr< gfx::texture > texture
Texture handle.
std::uint16_t mip
Mip level.
std::uint16_t layer
Cubemap side or depth layer/slice.
auto get_texture(std::uint32_t index=0) const -> const gfx::texture::ptr &
auto get_attachment_count() const -> size_t
auto get_attachments() const -> const std::vector< fbo_attachment > &
frame_buffer(void *_nwh, std::uint16_t _width, std::uint16_t _height, texture_format _format=texture_format::Count, texture_format _depth_format=texture_format::Count)
void populate(const std::vector< texture::ptr > &textures)
auto get_attachment(std::uint32_t index=0) const -> const fbo_attachment &
auto get_size() const -> usize32_t
frame_buffer()=default