cgv
Loading...
Searching...
No Matches
managed_frame_buffer.h
1#pragma once
2
3#include <unordered_map>
4
5#include <cgv/render/frame_buffer.h>
6
7#include "lib_begin.h"
8
9namespace cgv {
10namespace render {
11
14{
15private:
16 ivec2 get_actual_size(context& ctx);
17
18 bool create_and_validate(context& ctx, const ivec2& size);
19
20protected:
21 struct attachment {
22 unsigned index;
23 bool attach;
24 std::string format;
26 TextureWrap tw;
27 texture tex;
28
29 bool is_depth_attachment() {
30 return
31 format == "[D]" ||
32 format == "uint16[D]" ||
33 format == "uint32[D:24]" ||
34 format == "uint32[D]";
35 }
36 };
37
38 frame_buffer fb;
39 unsigned index_counter = 0;
40 std::unordered_map<std::string, attachment> attachments;
41 ivec2 size;
42
43public:
45
47
48 void destruct(const context& ctx);
49
50 ivec2 get_size();
51
57 bool set_size(const ivec2& size);
58
59 void add_attachment(const std::string& name, const std::string& format = "uint8[R,G,B]", TextureFilter tf = TF_NEAREST, TextureWrap tw = TW_CLAMP_TO_EDGE, bool attach = true);
60
61 bool enable_attachment(context& ctx, const std::string& name, int tex_unit = -1);
62
63 bool disable_attachment(context& ctx, const std::string& name);
64
65 texture* attachment_texture_ptr(const std::string& name);
66
67 bool ensure(context& ctx);
68
69 bool enable(context& ctx);
70
71 bool disable(context& ctx);
72
73 frame_buffer& ref_frame_buffer() { return fb; }
74};
75
76}
77}
78
79#include <cgv/config/lib_end.h>
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
this class encapsulate frame buffers that live on the GPU and can be used as destination for the rend...
provides a class that manages a frame buffer along with its attachments
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
TextureFilter
different texture filter
Definition context.h:189
TextureWrap
different texture wrap modes
Definition context.h:173
the cgv namespace
Definition print.h:11