cgv
|
OpenGL helper class to simplify depth peeling. More...
#include <gl_depth_peeler.h>
Public Member Functions | |
gl_depth_peeler (bool front_to_back=true, float _depth_bias=0.001) | |
construct uninitialized depth peeler | |
virtual | ~gl_depth_peeler () |
destruct the depth peeler | |
void | invert_t (bool enable=true) |
set the sign for the vertical texture coordinate. In case of some ATI-cards this needs to be enabled to avoid flipping intermediate textures. | |
void | set_back_to_front () |
enable back to front mode | |
void | set_front_to_back () |
enable front to back mode | |
bool | is_front_to_back () const |
return whether the mode is front to back | |
virtual void | destruct (context &ctx) |
destruct the depth peeler | |
void | set_depth_bias (float bias) |
the depth bias is used as epsilon for the test against the second depth buffer and is initialized to 0.0005f | |
float | get_depth_bias () const |
return the current depth bias | |
bool | is_initialized () const |
check whether the depth peeler has been initialized, i.e. the init method has been called successfully before | |
virtual bool | init (context &ctx) |
checks for extensions and init depth peeler, return success | |
virtual void | init_frame (context &ctx) |
call this after the viewport has been set and before the first call to copy_depth_buffer or begin_layer | |
void | copy_depth_buffer (context &ctx) |
copies the current depth buffer to the second depth buffer, what is typically done before peeling a layer | |
void | begin_layer (context &ctx, int tex_unit=-1) |
start to extract the next layer. Within begin_layer and end_layer the following OpenGL features are used: texture generation functions, 2D texturing and the alpha Test | |
unsigned int | end_layer (context &ctx) |
finish the layer and return the number of drawn fragments in the layer. All OpenGL settings are restored. | |
Public Attributes | |
std::string | last_error |
a string that contains the last error, which is only set by the init method | |
Protected Attributes | |
unsigned int | query |
texture | depth_texture |
float | depth_bias |
bool | front_to_back |
context * | ctx_ptr |
bool | _invert_t |
OpenGL helper class to simplify depth peeling.
Call the init method after your OpenGL context has been created. A sample usage during a drawing method would look like:
Definition at line 44 of file gl_depth_peeler.h.
cgv::render::gl::gl_depth_peeler::gl_depth_peeler | ( | bool | front_to_back = true , |
float | _depth_bias = 0.001 |
||
) |
construct uninitialized depth peeler
Definition at line 9 of file gl_depth_peeler.cxx.
|
virtual |
destruct the depth peeler
Definition at line 44 of file gl_depth_peeler.cxx.
References destruct(), and is_initialized().
void cgv::render::gl::gl_depth_peeler::begin_layer | ( | context & | ctx, |
int | tex_unit = -1 |
||
) |
start to extract the next layer. Within begin_layer and end_layer the following OpenGL features are used: texture generation functions, 2D texturing and the alpha Test
Definition at line 123 of file gl_depth_peeler.cxx.
References cgv::render::texture::enable(), and cgv::render::gl::ensure_glew_initialized().
Referenced by cgv::render::gl::gl_transparent_renderer::render_transparent().
void cgv::render::gl::gl_depth_peeler::copy_depth_buffer | ( | context & | ctx | ) |
copies the current depth buffer to the second depth buffer, what is typically done before peeling a layer
Definition at line 116 of file gl_depth_peeler.cxx.
References cgv::render::texture::replace_from_buffer().
Referenced by cgv::render::gl::gl_transparent_renderer::render_transparent().
|
virtual |
destruct the depth peeler
Reimplemented in cgv::render::gl::gl_transparent_renderer.
Definition at line 51 of file gl_depth_peeler.cxx.
References cgv::render::texture::destruct().
Referenced by cgv::render::gl::gl_transparent_renderer::destruct(), and ~gl_depth_peeler().
unsigned int cgv::render::gl::gl_depth_peeler::end_layer | ( | context & | ctx | ) |
finish the layer and return the number of drawn fragments in the layer. All OpenGL settings are restored.
finish the layer and return the number of drawn fragments in the layer
Definition at line 252 of file gl_depth_peeler.cxx.
References cgv::render::texture::disable().
Referenced by cgv::render::gl::gl_transparent_renderer::render_transparent().
float cgv::render::gl::gl_depth_peeler::get_depth_bias | ( | ) | const |
return the current depth bias
Definition at line 62 of file gl_depth_peeler.cxx.
|
virtual |
checks for extensions and init depth peeler, return success
Reimplemented in cgv::render::gl::gl_transparent_renderer.
Definition at line 74 of file gl_depth_peeler.cxx.
References cgv::render::gl::ensure_glew_initialized(), and last_error.
Referenced by cgv::render::gl::gl_transparent_renderer::init().
|
virtual |
call this after the viewport has been set and before the first call to copy_depth_buffer or begin_layer
Reimplemented in cgv::render::gl::gl_transparent_renderer.
Definition at line 100 of file gl_depth_peeler.cxx.
References cgv::render::texture::create(), cgv::render::texture::destruct(), cgv::data::data_format::get_height(), cgv::data::data_format::get_width(), cgv::render::render_component::is_created(), cgv::render::texture::set_compare_function(), cgv::render::texture::set_compare_mode(), cgv::data::data_format::set_height(), and cgv::data::data_format::set_width().
Referenced by cgv::render::gl::gl_transparent_renderer::init_frame().
void cgv::render::gl::gl_depth_peeler::invert_t | ( | bool | enable = true | ) |
set the sign for the vertical texture coordinate. In case of some ATI-cards this needs to be enabled to avoid flipping intermediate textures.
set the sign for y
Definition at line 20 of file gl_depth_peeler.cxx.
bool cgv::render::gl::gl_depth_peeler::is_front_to_back | ( | ) | const |
return whether the mode is front to back
Definition at line 38 of file gl_depth_peeler.cxx.
Referenced by cgv::render::gl::gl_transparent_renderer::init_frame().
bool cgv::render::gl::gl_depth_peeler::is_initialized | ( | ) | const |
check whether the depth peeler has been initialized, i.e. the init method has been called successfully before
Definition at line 68 of file gl_depth_peeler.cxx.
Referenced by ~gl_depth_peeler().
void cgv::render::gl::gl_depth_peeler::set_back_to_front | ( | ) |
enable back to front mode
Definition at line 26 of file gl_depth_peeler.cxx.
void cgv::render::gl::gl_depth_peeler::set_depth_bias | ( | float | bias | ) |
the depth bias is used as epsilon for the test against the second depth buffer and is initialized to 0.0005f
Definition at line 57 of file gl_depth_peeler.cxx.
void cgv::render::gl::gl_depth_peeler::set_front_to_back | ( | ) |
enable front to back mode
Definition at line 31 of file gl_depth_peeler.cxx.
|
protected |
Definition at line 52 of file gl_depth_peeler.h.
|
protected |
Definition at line 51 of file gl_depth_peeler.h.
|
protected |
Definition at line 49 of file gl_depth_peeler.h.
|
protected |
Definition at line 48 of file gl_depth_peeler.h.
|
protected |
Definition at line 50 of file gl_depth_peeler.h.
|
mutable |
a string that contains the last error, which is only set by the init method
Definition at line 55 of file gl_depth_peeler.h.
Referenced by init().
|
protected |
Definition at line 47 of file gl_depth_peeler.h.