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:670
frame_buffer_base()
initialize members
Definition context.cxx:2498
bool create(const context &ctx, int _width=-1, int _height=-1)
create framebuffer if extension is supported, otherwise return false.
static int get_max_nr_color_attachments(const context &ctx)
return the maximum number of color attachments supported by the GPU
int get_width() const
return the width
void set_size(int _width, int _height)
set different size
void destruct(const context &ctx)
destruct the framebuffer objext
static int get_max_nr_draw_buffers(const context &ctx)
return the maximum number of simultaneous draw buffers supported by the GPU
frame_buffer()
constructor just initializes stuff
void set_height(int _height)
set a different height
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
void set_width(int _width)
set a different width
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
namespace for api independent GPU programming
BufferTypeBits
Bits for the selection of different buffer types.
Definition context.h:519
@ BTB_ALL_BITS
all buffer types
Definition context.h:524
this header is dependency free
Definition print.h:11
cgv::math::fvec< int32_t, 4 > ivec4
declare type of 4d 32 bit integer vectors
Definition fvec.h:723
cgv::math::fvec< double, 2 > dvec2
declare type of 2d double precision floating point vectors
Definition fvec.h:699