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