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

this class encapsulate render buffers that live on the GPU which must support frame buffer objects for this to work. More...

#include <render_buffer.h>

Inheritance diagram for cgv::render::render_buffer:
cgv::render::render_buffer_base cgv::data::component_format cgv::render::render_component cgv::data::packing_info

Public Member Functions

 render_buffer (const std::string &description="[R,G,B,A]")
 construct from description of component format, where the default format specifies a color buffer with alpha channel
 
void set_nr_multi_samples (unsigned _nr_samples)
 set the number of multi samples, which should be done before create
 
void destruct (const context &ctx)
 destruct the render buffer
 
bool create (const context &ctx, int width=-1, int height=-1)
 create a render buffer.
 
bool is_created () const override
 check whether the buffer has been created
 
 ~render_buffer ()
 calls the destruct method if necessary
 
int get_width () const
 return the width in pixels of the buffer
 
int get_height () const
 return the height in pixels of the buffer
 
bool is_multi_buffer () const
 whether this buffer is a multi sample buffer
 
unsigned get_nr_multi_samples () const
 return number of multi samples
 
bool is_depth_buffer () const
 return whether the component format corresponds to a depth buffer format
 
bool is_color_buffer () const
 return whether the component format corresponds to a color buffer format
 
- Public Member Functions inherited from cgv::render::render_component
 render_component ()
 initialize members
 
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
 
- Public Member Functions inherited from cgv::data::component_format
 component_format (const std::string &description)
 construct from description string, see set_component_format for docu
 
bool set_component_format (const std::string &description)
 set component format from description string, which has the following syntax.
 
void set_components (const std::string &_components)
 comma separated list of component descriptors, for example "R,G,B"
 
 component_format (cgv::type::info::TypeId _component_type=cgv::type::info::TypeId::TI_UNDEF, const std::string &_component_name_list="", unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct component format from component type, comma or colon separated list of component names, component alignment and bit depths for packed formats
 
 component_format (cgv::type::info::TypeId _component_type, ComponentFormat cf, unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct component format from component type, standard component format, component alignment and bit depths for packed formats
 
void set_integer_interpretation (ComponentIntegerInterpretation cii)
 set the integer interpretation
 
ComponentIntegerInterpretation get_integer_interpretation () const
 return current integer interpretation
 
template<typename T >
get (int ci, const void *ptr) const
 constant access to the i-th component stored at the given location
 
template<typename T >
bool set (int ci, void *ptr, const T &v) const
 write access to the i-th component, return whether write was successful
 
bool empty () const
 return whether the component format is defined
 
void clear ()
 clear the component format
 
const packing_infoget_packing_info () const
 return the packing info by simple conversion of the this pointer
 
void set_packing_info (const packing_info &pi)
 set packing info by simply assigning to a converted this pointer
 
unsigned int get_nr_components () const
 return the number of components
 
unsigned int get_component_index (const std::string &name) const
 return the index of a component given by name or -1 if not found
 
std::string get_component_name (unsigned int i) const
 return the name of the component with index i
 
ComponentFormat get_standard_component_format () const
 return whether the component format is one of the standard formats
 
void set_component_names (const std::string &_component_name_list)
 set component names from a comma or colon separated list of names
 
void set_component_format (ComponentFormat _cf)
 set the component names from a standard component format
 
cgv::type::info::TypeId get_component_type () const
 return the component type
 
void set_component_type (cgv::type::info::TypeId _type_id)
 set the component type
 
unsigned int get_entry_size () const
 return the size of one entry of components in bytes
 
bool operator== (const component_format &cf) const
 comparison between component formats
 
bool operator!= (const component_format &cf) const
 comparison between component formats
 
- Public Member Functions inherited from cgv::data::packing_info
 packing_info (unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct packing information from alignment and bit depths.
 
void clear ()
 clear packing info information
 
unsigned get_bit_depth (unsigned ci) const
 return the bit depth of the ci-th component
 
void set_bit_depth (unsigned ci, unsigned depth)
 set the bit depth of the ci-th component
 
bool is_packing () const
 return whether packing is enabled
 
void set_packing (bool enable=true)
 set the packing flag
 
unsigned int get_component_alignment () const
 return the component alignment in bits in the packed case and in bytes in the unpacked case
 
void set_component_alignment (unsigned a)
 set the component alignment in bits in the packed case and in bytes in the unpacked case
 
int get_signed (unsigned ci, const void *ptr) const
 return the ci-th component of the data entry pointed to by the given pointer of a signed packed component
 
unsigned int get_unsigned (unsigned ci, const void *ptr) const
 return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
 
bool set_signed (unsigned ci, void *ptr, int v) const
 set the ci-th component of the data entry pointed to by the given pointer of a signed packed component
 
bool set_unsigned (unsigned ci, void *ptr, unsigned v) const
 set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
 
bool operator== (const packing_info &pi) const
 equal comparison
 
bool operator!= (const packing_info &pi) const
 unequal comparison
 

Public Attributes

std::string last_error
 a string that contains the last error
 
- Public Attributes inherited from cgv::render::render_buffer_base
unsigned nr_multi_samples = 0
 
- 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

- Static Public Member Functions inherited from cgv::data::component_format
static const std::string & get_last_error ()
 returns an error string after parsing of description string has failed
 
- Static Public Member Functions inherited from cgv::data::packing_info
static size_t align (size_t v, unsigned a)
 return the next integer larger or equal to v which is dividable by a
 
- Protected Member Functions inherited from cgv::data::component_format
void extract_components ()
 extract components from component string
 
- Protected Member Functions inherited from cgv::data::packing_info
bool prepare_bit_operation (unsigned ci, void *ptr, unsigned &off, unsigned &bd, unsigned *&iptr) const
 
bool prepare_bit_operation (unsigned ci, const void *ptr, unsigned &off, unsigned &bd, const unsigned *&iptr) const
 
unsigned int get_bit_offset (unsigned ci) const
 
- Protected Attributes inherited from cgv::data::component_format
cgv::type::info::TypeId component_type
 store the type id of the component type
 
ComponentIntegerInterpretation component_interpretation
 interpretation of integer typed components
 
std::string component_string
 store all component names in one string separated with 0-chars
 
std::vector< unsigned short > component_positions
 store the position of each component in the component string
 
- Protected Attributes inherited from cgv::data::packing_info
bool is_packed: 1
 
unsigned bd0: 6
 
unsigned bd1: 6
 
unsigned bd2: 6
 
unsigned bd3: 6
 
unsigned ca: 6
 
- Static Protected Attributes inherited from cgv::data::component_format
static std::string last_error
 store the last error that appeared during parsing of a description
 

Detailed Description

this class encapsulate render buffers that live on the GPU which must support frame buffer objects for this to work.

Definition at line 13 of file render_buffer.h.

Constructor & Destructor Documentation

◆ render_buffer()

cgv::render::render_buffer::render_buffer ( const std::string &  description = "[R,G,B,A]")

construct from description of component format, where the default format specifies a color buffer with alpha channel

Definition at line 6 of file render_buffer.cxx.

◆ ~render_buffer()

cgv::render::render_buffer::~render_buffer ( )

calls the destruct method if necessary

Definition at line 19 of file render_buffer.cxx.

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

Member Function Documentation

◆ create()

bool cgv::render::render_buffer::create ( const context ctx,
int  width = -1,
int  height = -1 
)

create a render buffer.

If no extent is specified it is copied from the current viewport.

Definition at line 41 of file render_buffer.cxx.

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

Referenced by cgv::render::texture::write_to_file().

◆ destruct()

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

destruct the render buffer

Definition at line 29 of file render_buffer.cxx.

Referenced by create(), and ~render_buffer().

◆ get_height()

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

return the height in pixels of the buffer

Definition at line 37 of file render_buffer.h.

◆ get_nr_multi_samples()

unsigned cgv::render::render_buffer::get_nr_multi_samples ( ) const
inline

return number of multi samples

Definition at line 41 of file render_buffer.h.

◆ get_width()

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

return the width in pixels of the buffer

Definition at line 35 of file render_buffer.h.

◆ is_color_buffer()

bool cgv::render::render_buffer::is_color_buffer ( ) const

return whether the component format corresponds to a color buffer format

Definition at line 59 of file render_buffer.cxx.

References cgv::data::CF_RGB, cgv::data::CF_RGBA, and cgv::data::component_format::get_standard_component_format().

◆ is_created()

bool cgv::render::render_buffer::is_created ( ) const
overridevirtual

check whether the buffer has been created

Reimplemented from cgv::render::render_component.

Definition at line 36 of file render_buffer.cxx.

◆ is_depth_buffer()

bool cgv::render::render_buffer::is_depth_buffer ( ) const

return whether the component format corresponds to a depth buffer format

Definition at line 54 of file render_buffer.cxx.

References cgv::data::CF_D, and cgv::data::component_format::get_standard_component_format().

Referenced by cgv::render::frame_buffer::attach().

◆ is_multi_buffer()

bool cgv::render::render_buffer::is_multi_buffer ( ) const
inline

whether this buffer is a multi sample buffer

Definition at line 39 of file render_buffer.h.

◆ set_nr_multi_samples()

void cgv::render::render_buffer::set_nr_multi_samples ( unsigned  _nr_samples)

set the number of multi samples, which should be done before create

Definition at line 14 of file render_buffer.cxx.

Member Data Documentation

◆ last_error

std::string cgv::render::render_component::last_error
mutable

a string that contains the last error

Definition at line 309 of file context.h.


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