cgv
Loading...
Searching...
No Matches
frame_buffer.h
1#pragma once
2
3#include <cgv/data/component_format.h>
4#include <cgv/render/texture.h>
5#include <cgv/render/render_buffer.h>
6#include <cgv/render/context.h>
7
8#include "lib_begin.h"
9
10namespace cgv {
11 namespace render {
12
16class CGV_API frame_buffer : public frame_buffer_base
17{
18public:
20 static int get_max_nr_color_attachments(const context& ctx);
22 static int get_max_nr_draw_buffers(const context& ctx);
24 mutable std::string last_error;
30 void destruct(const context& ctx);
34 bool create(const context& ctx, int _width = -1, int _height = -1);
36 void set_width(int _width);
38 void set_height(int _height);
40 void set_size(int _width, int _height);
42 int get_width() const { return width; }
44 int get_height() const { return height; }
45
47 bool attach(const context& ctx, const render_buffer& rb, int i = 0);
49 bool attach(const context& ctx, const texture& tex2d, int level = 0, int i = 0);
51 bool attach(const context& ctx, const texture& tex3d, int z_or_cube_side, int level, int i);
53 bool is_complete(const context& ctx) const;
57 bool enable(context& ctx, int i0 = -1, int i1 = -1, int i2 = -1, int i3 = -1
58 , int i4 = -1, int i5 = -1, int i6 = -1, int i7 = -1
59 , int i8 = -1, int i9 = -1, int i10= -1, int i11= -1
60 , int i12= -1, int i13= -1, int i14= -1, int i15= -1);
63 bool enable(context& ctx, std::vector<int>& indices);
65 void push_viewport(context& ctx, const dvec2& depth_range = dvec2(0,1));
67 void pop_viewport(context& ctx);
69 bool disable(context& ctx);
71 void blit_to(context& ctx, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) const { blit_to(ctx, ivec4(0, 0, width, height), ivec4(-1), btbs, interpolate); }
72 void blit_to(context& ctx, const ivec4& src_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) const { blit_to(ctx, src_rect, ivec4(-1), btbs, interpolate); }
73 void blit_to(context& ctx, const ivec4& src_rect, const ivec4& dst_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) const;
74 void blit_to(context& ctx, frame_buffer& dst_fbo, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) const { blit_to(ctx, dst_fbo, ivec4(0, 0, width, height), ivec4(0, 0, dst_fbo.width, dst_fbo.height), btbs, interpolate); }
75 void blit_to(context& ctx, frame_buffer& dst_fbo, const ivec4& src_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) const { blit_to(ctx, dst_fbo, src_rect, ivec4(0, 0, dst_fbo.width, dst_fbo.height), btbs, interpolate); }
76 void blit_to(context& ctx, frame_buffer& dst_fbo, const ivec4& src_rect, const ivec4& dst_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) const;
78 void blit_from(context& ctx, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) { blit_from(ctx, ivec4(0, 0, width, height), ivec4(-1), btbs, interpolate); }
79 void blit_from(context& ctx, const ivec4& dst_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) { blit_from(ctx, dst_rect, ivec4(-1), btbs, interpolate); }
80 void blit_from(context& ctx, const ivec4& dst_rect, const ivec4& src_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false);
81 void blit_from(context& ctx, frame_buffer& src_fbo, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) { blit_from(ctx, src_fbo, ivec4(0, 0, width, height), ivec4(0, 0, src_fbo.width, src_fbo.height), btbs, interpolate); }
82 void blit_from(context& ctx, frame_buffer& src_fbo, const ivec4& dst_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false) { blit_to(ctx, src_fbo, dst_rect, ivec4(0, 0, src_fbo.width, src_fbo.height), btbs, interpolate); }
83 void blit_from(context& ctx, frame_buffer& src_fbo, const ivec4& dst_rect, const ivec4& src_rect, BufferTypeBits btbs = BTB_ALL_BITS, bool interpolate = false);
84};
85
86 }
87}
88
89#include <cgv/config/lib_end.h>
90
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
base interface for framebuffer
Definition context.h:471
this class encapsulate frame buffers that live on the GPU and can be used as destination for the rend...
int get_width() const
return the width
void blit_to(context &ctx, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false) const
different variants of blitting rectangle src_rect of this frame buffer into rectangle dest_rect of de...
std::string last_error
a string that contains the last error, which is only set by the init method
int get_height() const
return the height
void blit_from(context &ctx, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false)
different variants of blitting to rectangle dst_rect of this frame buffer from rectangle src_rect of ...
this class encapsulate render buffers that live on the GPU which must support frame buffer objects fo...
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
BufferTypeBits
Bits for the selection of different buffer types.
Definition context.h:461
the cgv namespace
Definition print.h:11