cgv
Loading...
Searching...
No Matches
render_buffer.cxx
1#include "render_buffer.h"
2
3namespace cgv {
4 namespace render {
5
6render_buffer::render_buffer(const std::string& description)
7 : cgv::data::component_format(description)
8{
9 width = -1;
10 height = -1;
11 handle = 0;
12}
13
14void render_buffer::set_nr_multi_samples(unsigned _nr_samples)
15{
16 nr_multi_samples = _nr_samples;
17}
18
20{
21 if (handle) {
22 if (ctx_ptr)
24 else
25 std::cerr << "could not destruct render buffer in destructor" << std::endl;
26 }
27}
28
30{
31 if (handle) {
32 ctx.render_buffer_destruct(*this);
33 }
34}
35
37{
38 return handle != 0;
39}
40
41bool render_buffer::create(const context& ctx, int _width, int _height)
42{
43 if (ctx_ptr)
45 else
46 destruct(ctx);
47 bool res = ctx.render_buffer_create(*this, *this, _width, _height);
48 ctx_ptr = &ctx;
49 width = _width;
50 height = _height;
51 return res;
52}
53
58
64
65
66 }
67}
ComponentFormat get_standard_component_format() const
return whether the component format is one of the standard formats
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
bool create(const context &ctx, int width=-1, int height=-1)
create a 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 wit...
bool is_depth_buffer() const
return whether the component format corresponds to a depth buffer format
void set_nr_multi_samples(unsigned _nr_samples)
set the number of multi samples, which should be done before create
bool is_color_buffer() const
return whether the component format corresponds to a color buffer format
bool is_created() const override
check whether the buffer has been created
void destruct(const context &ctx)
destruct the render buffer
~render_buffer()
calls the destruct method if necessary
const context * ctx_ptr
keep pointer to my context
Definition context.h:307
@ CF_RGBA
color format with components R, G and B
@ CF_RGB
color format with two components R and G
@ CF_D
color format with components B, G, R and A
the cgv namespace
Definition print.h:11