cgv
Loading...
Searching...
No Matches
cgv::render::frame_buffer Class Reference

this class encapsulate frame buffers that live on the GPU and can be used as destination for the render process. More...

#include <frame_buffer.h>

Inheritance diagram for cgv::render::frame_buffer:
cgv::render::frame_buffer_base cgv::render::render_component

Public Member Functions

 frame_buffer ()
 constructor just initializes stuff
 
 ~frame_buffer ()
 destructor
 
void destruct (const context &ctx)
 destruct the framebuffer objext
 
bool create (const context &ctx, int _width=-1, int _height=-1)
 create framebuffer if extension is supported, otherwise return false.
 
void set_width (int _width)
 set a different width
 
void set_height (int _height)
 set a different height
 
void set_size (int _width, int _height)
 set different size
 
int get_width () const
 return the width
 
int get_height () const
 return the height
 
bool attach (const context &ctx, const render_buffer &rb, int i=0)
 attach render buffer to depth buffer if it is a depth buffer, to stencil if it is a stencil buffer or to the i-th color attachment if it is a color buffer
 
bool attach (const context &ctx, const texture &tex2d, int level=0, int i=0)
 attach 2d texture to depth buffer if it is a depth texture, to stencil if it is a stencil texture or to the i-th color attachment if it is a color texture
 
bool attach (const context &ctx, const texture &tex3d, int z_or_cube_side, int level, int i)
 attach the j-th slice of a 3d texture or the given cube side of a cubemap to the i-th color attachment
 
bool is_complete (const context &ctx) const
 check for completeness, if not complete, get the reason in last_error
 
bool enable (context &ctx, int i0=-1, int i1=-1, int i2=-1, int i3=-1, int i4=-1, int i5=-1, int i6=-1, int i7=-1, int i8=-1, int i9=-1, int i10=-1, int i11=-1, int i12=-1, int i13=-1, int i14=-1, int i15=-1)
 enable the framebuffer either with all color attachments if no arguments are given or if arguments are given with the indexed color attachments.
 
bool enable (context &ctx, std::vector< int > &indices)
 enable the framebuffer either with the color attachments specified in the given vector.
 
void push_viewport (context &ctx, const dvec2 &depth_range=dvec2(0, 1))
 push a new window transformation to cover the fbo onto the window transformation stack
 
void pop_viewport (context &ctx)
 recover the window transformation array active before the last call to push_viewport
 
bool disable (context &ctx)
 disable the framebuffer object
 
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 destination frame buffer
 
void blit_to (context &ctx, const ivec4 &src_rect, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false) const
 
void blit_to (context &ctx, const ivec4 &src_rect, const ivec4 &dst_rect, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false) const
 
void blit_to (context &ctx, frame_buffer &dst_fbo, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false) const
 
void blit_to (context &ctx, frame_buffer &dst_fbo, const ivec4 &src_rect, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false) const
 
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
 
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 source frame buffer
 
void blit_from (context &ctx, const ivec4 &dst_rect, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false)
 
void blit_from (context &ctx, const ivec4 &dst_rect, const ivec4 &src_rect, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false)
 
void blit_from (context &ctx, frame_buffer &src_fbo, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false)
 
void blit_from (context &ctx, frame_buffer &src_fbo, const ivec4 &dst_rect, BufferTypeBits btbs=BTB_ALL_BITS, bool interpolate=false)
 
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)
 
- Public Member Functions inherited from cgv::render::frame_buffer_base
 frame_buffer_base ()
 initialize members
 
- Public Member Functions inherited from cgv::render::render_component
 render_component ()
 initialize members
 
virtual bool is_created () const
 return whether component has been created
 
void put_id_void (void *ptr) const
 copy the rendering api specific id the component to the memory location of the given pointer.
 
template<typename T >
void put_id (T &id) const
 cast the refence to rendering api specific representation of component id to the specified type
 

Static Public Member Functions

static int get_max_nr_color_attachments (const context &ctx)
 return the maximum number of color attachments supported by the GPU
 
static int get_max_nr_draw_buffers (const context &ctx)
 return the maximum number of simultaneous draw buffers supported by the GPU
 

Public Attributes

std::string last_error
 a string that contains the last error, which is only set by the init method
 
- Public Attributes inherited from cgv::render::render_component
void * handle
 
void * internal_format
 
void * user_data
 
const contextctx_ptr
 keep pointer to my context
 
std::string last_error
 a string that contains the last error
 

Additional Inherited Members

- Protected Attributes inherited from cgv::render::frame_buffer_base
bool is_enabled
 
std::vector< int > enabled_color_attachments
 
bool depth_attached
 
bool attached [16]
 
int width
 
int height
 

Detailed Description

this class encapsulate frame buffers that live on the GPU and can be used as destination for the render process.

The GPU must support frame buffer objects for this to work.

Definition at line 16 of file frame_buffer.h.

Constructor & Destructor Documentation

◆ frame_buffer()

cgv::render::frame_buffer::frame_buffer ( )

constructor just initializes stuff

Definition at line 6 of file frame_buffer.cxx.

◆ ~frame_buffer()

cgv::render::frame_buffer::~frame_buffer ( )

destructor

Definition at line 33 of file frame_buffer.cxx.

References cgv::render::render_component::ctx_ptr, and destruct().

Member Function Documentation

◆ attach() [1/3]

bool cgv::render::frame_buffer::attach ( const context ctx,
const render_buffer rb,
int  i = 0 
)

attach render buffer to depth buffer if it is a depth buffer, to stencil if it is a stencil buffer or to the i-th color attachment if it is a color buffer

Definition at line 82 of file frame_buffer.cxx.

References cgv::render::render_buffer::is_depth_buffer().

Referenced by cgv::render::gl::gl_transparent_renderer::create_and_attach_texture(), vr_test::init_frame(), cgv::render::gl::render_to_texture3D(), and cgv::render::texture::write_to_file().

◆ attach() [2/3]

bool cgv::render::frame_buffer::attach ( const context ctx,
const texture tex2d,
int  level = 0,
int  i = 0 
)

attach 2d texture to depth buffer if it is a depth texture, to stencil if it is a stencil texture or to the i-th color attachment if it is a color texture

Definition at line 88 of file frame_buffer.cxx.

References cgv::data::CF_D, cgv::render::texture::ensure_state(), cgv::data::data_format::get_nr_dimensions(), cgv::data::component_format::get_standard_component_format(), and last_error.

◆ attach() [3/3]

bool cgv::render::frame_buffer::attach ( const context ctx,
const texture tex3d,
int  z_or_cube_side,
int  level,
int  i 
)

attach the j-th slice of a 3d texture or the given cube side of a cubemap to the i-th color attachment

attach the j-th slice of a 3d texture to the i-th color attachment

Definition at line 99 of file frame_buffer.cxx.

References cgv::data::CF_D, cgv::render::texture::ensure_state(), cgv::data::data_format::get_nr_dimensions(), cgv::data::component_format::get_standard_component_format(), and last_error.

◆ blit_from() [1/6]

void cgv::render::frame_buffer::blit_from ( context ctx,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
)
inline

different variants of blitting to rectangle dst_rect of this frame buffer from rectangle src_rect of source frame buffer

Definition at line 78 of file frame_buffer.h.

References blit_from().

Referenced by blit_from().

◆ blit_from() [2/6]

void cgv::render::frame_buffer::blit_from ( context ctx,
const ivec4 dst_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
)
inline

Definition at line 79 of file frame_buffer.h.

◆ blit_from() [3/6]

void cgv::render::frame_buffer::blit_from ( context ctx,
const ivec4 dst_rect,
const ivec4 src_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
)

Definition at line 22 of file frame_buffer.cxx.

◆ blit_from() [4/6]

void cgv::render::frame_buffer::blit_from ( context ctx,
frame_buffer src_fbo,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
)
inline

Definition at line 81 of file frame_buffer.h.

◆ blit_from() [5/6]

void cgv::render::frame_buffer::blit_from ( context ctx,
frame_buffer src_fbo,
const ivec4 dst_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
)
inline

Definition at line 82 of file frame_buffer.h.

◆ blit_from() [6/6]

void cgv::render::frame_buffer::blit_from ( context ctx,
frame_buffer src_fbo,
const ivec4 dst_rect,
const ivec4 src_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
)

Definition at line 27 of file frame_buffer.cxx.

◆ blit_to() [1/6]

void cgv::render::frame_buffer::blit_to ( context ctx,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
) const
inline

different variants of blitting rectangle src_rect of this frame buffer into rectangle dest_rect of destination frame buffer

Definition at line 71 of file frame_buffer.h.

References blit_to().

Referenced by blit_to().

◆ blit_to() [2/6]

void cgv::render::frame_buffer::blit_to ( context ctx,
const ivec4 src_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
) const
inline

Definition at line 72 of file frame_buffer.h.

◆ blit_to() [3/6]

void cgv::render::frame_buffer::blit_to ( context ctx,
const ivec4 src_rect,
const ivec4 dst_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
) const

Definition at line 12 of file frame_buffer.cxx.

◆ blit_to() [4/6]

void cgv::render::frame_buffer::blit_to ( context ctx,
frame_buffer dst_fbo,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
) const
inline

Definition at line 74 of file frame_buffer.h.

◆ blit_to() [5/6]

void cgv::render::frame_buffer::blit_to ( context ctx,
frame_buffer dst_fbo,
const ivec4 src_rect,
BufferTypeBits  btbs = BTB_ALL_BITS,
bool  interpolate = false 
) const
inline

Definition at line 75 of file frame_buffer.h.

◆ blit_to() [6/6]

void cgv::render::frame_buffer::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

Definition at line 17 of file frame_buffer.cxx.

◆ create()

bool cgv::render::frame_buffer::create ( const context ctx,
int  _width = -1,
int  _height = -1 
)

create framebuffer if extension is supported, otherwise return false.

create framebuffer of extension is supported, otherwise return false.

The set extent is used to set the viewport in the enable method. If no extent is specified it is copied from glViewport.

Definition at line 51 of file frame_buffer.cxx.

References cgv::render::render_component::ctx_ptr, and destruct().

Referenced by vr_test::init_frame(), cgv::render::gl::gl_transparent_renderer::init_frame(), cgv::render::gl::render_to_texture3D(), and cgv::render::texture::write_to_file().

◆ destruct()

void cgv::render::frame_buffer::destruct ( const context ctx)

◆ disable()

bool cgv::render::frame_buffer::disable ( context ctx)

◆ enable() [1/2]

bool cgv::render::frame_buffer::enable ( context ctx,
int  i0 = -1,
int  i1 = -1,
int  i2 = -1,
int  i3 = -1,
int  i4 = -1,
int  i5 = -1,
int  i6 = -1,
int  i7 = -1,
int  i8 = -1,
int  i9 = -1,
int  i10 = -1,
int  i11 = -1,
int  i12 = -1,
int  i13 = -1,
int  i14 = -1,
int  i15 = -1 
)

enable the framebuffer either with all color attachments if no arguments are given or if arguments are given with the indexed color attachments.

Return whether this was successful.

Definition at line 121 of file frame_buffer.cxx.

Referenced by vr_test::init_frame(), cgv::render::gl::render_to_texture3D(), cgv::render::gl::gl_transparent_renderer::render_transparent(), and cgv::render::texture::write_to_file().

◆ enable() [2/2]

bool cgv::render::frame_buffer::enable ( context ctx,
std::vector< int > &  indices 
)

enable the framebuffer either with the color attachments specified in the given vector.

Definition at line 162 of file frame_buffer.cxx.

◆ get_height()

int cgv::render::frame_buffer::get_height ( ) const
inline

return the height

Definition at line 44 of file frame_buffer.h.

Referenced by cgv::render::gl::gl_transparent_renderer::init_frame(), and push_viewport().

◆ get_max_nr_color_attachments()

int cgv::render::frame_buffer::get_max_nr_color_attachments ( const context ctx)
static

return the maximum number of color attachments supported by the GPU

Definition at line 188 of file frame_buffer.cxx.

◆ get_max_nr_draw_buffers()

int cgv::render::frame_buffer::get_max_nr_draw_buffers ( const context ctx)
static

return the maximum number of simultaneous draw buffers supported by the GPU

Definition at line 193 of file frame_buffer.cxx.

◆ get_width()

int cgv::render::frame_buffer::get_width ( ) const
inline

return the width

Definition at line 42 of file frame_buffer.h.

Referenced by vr_test::init_frame(), cgv::render::gl::gl_transparent_renderer::init_frame(), and push_viewport().

◆ is_complete()

bool cgv::render::frame_buffer::is_complete ( const context ctx) const

check for completeness, if not complete, get the reason in last_error

Definition at line 113 of file frame_buffer.cxx.

Referenced by vr_test::init_frame(), cgv::render::gl::gl_transparent_renderer::init_frame(), cgv::render::gl::render_to_texture3D(), and cgv::render::texture::write_to_file().

◆ pop_viewport()

void cgv::render::frame_buffer::pop_viewport ( context ctx)

recover the window transformation array active before the last call to push_viewport

Definition at line 177 of file frame_buffer.cxx.

References cgv::render::context::pop_window_transformation_array().

Referenced by vr_test::init_frame().

◆ push_viewport()

void cgv::render::frame_buffer::push_viewport ( context ctx,
const dvec2 depth_range = dvec2(0,1) 
)

push a new window transformation to cover the fbo onto the window transformation stack

Definition at line 169 of file frame_buffer.cxx.

References get_height(), get_width(), cgv::render::context::push_window_transformation_array(), cgv::render::context::set_depth_range(), and cgv::render::context::set_viewport().

Referenced by vr_test::init_frame().

◆ set_height()

void cgv::render::frame_buffer::set_height ( int  _height)

set a different height

Definition at line 69 of file frame_buffer.cxx.

◆ set_size()

void cgv::render::frame_buffer::set_size ( int  _width,
int  _height 
)

set different size

Definition at line 75 of file frame_buffer.cxx.

◆ set_width()

void cgv::render::frame_buffer::set_width ( int  _width)

set a different width

Definition at line 64 of file frame_buffer.cxx.

Member Data Documentation

◆ last_error

std::string cgv::render::frame_buffer::last_error
mutable

a string that contains the last error, which is only set by the init method

Definition at line 24 of file frame_buffer.h.

Referenced by attach(), attach(), and cgv::render::texture::write_to_file().


The documentation for this class was generated from the following files: