cgv
|
This class provides a_buffer functionality. More...
#include <a_buffer.h>
Public Member Functions | |
a_buffer (unsigned _fragments_per_pixel=32, unsigned _nodes_per_pixel=64, int _depth_tex_unit=0, int _node_counter_binding_point=0, int _head_pointers_binding_point=0, int _nodes_binding_point=1) | |
construct and configure | |
bool | init (context &ctx) |
construct internally used programs | |
void | destruct (context &ctx) |
destruct all render objects | |
void | init_frame (context &ctx) |
ensure that a_buffer size corresponds to context size | |
void | update_defines (shader_define_map &defines) |
update the provided shader defines with respect to a_buffer settings. Call before enabling a program. | |
bool | enable (context &ctx, shader_program &prog, int tex_unit=-1) |
Enable writing fragments to a_buffer with provided program. | |
size_t | disable (context &ctx) |
finish writing fragments to a_buffer and return current number of nodes in node buffer | |
void | finish_frame (context &ctx) |
per fragment sort nodes and blend over current framebuffer | |
int & | ref_depth_tex_unit () |
int & | ref_node_counter_binding_point () |
int & | ref_head_pointers_binding_point () |
int & | ref_nodes_binding_point () |
Public Attributes | |
unsigned | fragments_per_pixel |
to be handled fragments per pixel (changes are applied when in init_frame() function) | |
unsigned | nodes_per_pixel |
to be reserved number of fragment nodes per pixel (changes are applied when in init_frame() function) | |
Protected Member Functions | |
void | destruct_buffers (context &ctx) |
void | ensure_buffers (context &ctx) |
void | update_defines (shader_define_map &defines, bool include_binding_points) |
Static Protected Member Functions | |
static void | ensure_buffer (GLuint &buffer, GLenum target, GLsizeiptr size, const void *data, GLenum usage=GL_DYNAMIC_DRAW) |
static void | destruct_buffer (GLuint &buffer) |
Protected Attributes | |
texture | depth_tex |
Depth texture used to emulate depth buffer. | |
unsigned | node_buffer_counter |
Buffers used to store per pixel frament lists. | |
unsigned | head_pointer_buffer |
unsigned | node_buffer |
int | depth_tex_unit |
Default texture unit used for depth texture. | |
int | node_counter_binding_point |
Buffer binding point indices. | |
int | head_pointers_binding_point |
int | nodes_binding_point |
shader_program | clear_ssbo_prog |
shader_program | a_buffer_prog |
This class provides a_buffer functionality.
Compare cgv/test/a_buffer_test for an example of using this class.
Definition at line 14 of file a_buffer.h.
cgv::render::a_buffer::a_buffer | ( | unsigned | _fragments_per_pixel = 32 , |
unsigned | _nodes_per_pixel = 64 , |
||
int | _depth_tex_unit = 0 , |
||
int | _node_counter_binding_point = 0 , |
||
int | _head_pointers_binding_point = 0 , |
||
int | _nodes_binding_point = 1 |
||
) |
construct and configure
Definition at line 67 of file a_buffer.cxx.
References depth_tex, depth_tex_unit, fragments_per_pixel, node_buffer_counter, node_counter_binding_point, nodes_per_pixel, cgv::render::texture::set_mag_filter(), and cgv::render::texture::set_min_filter().
void cgv::render::a_buffer::destruct | ( | context & | ctx | ) |
destruct all render objects
Definition at line 97 of file a_buffer.cxx.
References depth_tex, cgv::render::shader_program::destruct(), and cgv::render::texture::destruct().
|
staticprotected |
Definition at line 16 of file a_buffer.cxx.
|
protected |
Definition at line 23 of file a_buffer.cxx.
size_t cgv::render::a_buffer::disable | ( | context & | ctx | ) |
finish writing fragments to a_buffer and return current number of nodes in node buffer
Definition at line 177 of file a_buffer.cxx.
References depth_tex, cgv::render::texture::disable(), node_buffer_counter, and node_counter_binding_point.
bool cgv::render::a_buffer::enable | ( | context & | ctx, |
shader_program & | prog, | ||
int | tex_unit = -1 |
||
) |
Enable writing fragments to a_buffer with provided program.
In first call after each init frame call, the current depth buffer is copied to a_buffer's depth texture. Function sets necessary uniforms in program and binds depth texture and buffers. In a_buffer constructor depth texture unit can be overwritten by third argument. Function fails by returning false if program query of binding points to buffers fail.
Definition at line 146 of file a_buffer.cxx.
References depth_tex, depth_tex_unit, cgv::render::texture::enable(), cgv::render::context::get_height(), cgv::render::context::get_width(), node_buffer_counter, node_counter_binding_point, nodes_per_pixel, cgv::render::texture::replace_from_buffer(), and cgv::render::shader_program::set_uniform().
|
staticprotected |
Definition at line 6 of file a_buffer.cxx.
|
protected |
Definition at line 29 of file a_buffer.cxx.
void cgv::render::a_buffer::finish_frame | ( | context & | ctx | ) |
per fragment sort nodes and blend over current framebuffer
Definition at line 193 of file a_buffer.cxx.
References cgv::render::shader_program::disable(), cgv::render::shader_program::enable(), cgv::render::context::get_height(), cgv::render::context::get_width(), nodes_per_pixel, and cgv::render::shader_program::set_uniform().
bool cgv::render::a_buffer::init | ( | context & | ctx | ) |
construct internally used programs
Definition at line 87 of file a_buffer.cxx.
References cgv::render::shader_program::build_files(), and cgv::render::shader_program::build_program().
void cgv::render::a_buffer::init_frame | ( | context & | ctx | ) |
ensure that a_buffer size corresponds to context size
Definition at line 104 of file a_buffer.cxx.
References cgv::render::shader_program::build_program(), cgv::render::texture::create(), depth_tex, cgv::render::shader_program::destruct(), cgv::render::texture::destruct(), cgv::render::shader_program::disable(), cgv::render::shader_program::enable(), cgv::data::data_format::get_height(), cgv::render::context::get_height(), cgv::data::data_format::get_width(), cgv::render::context::get_width(), cgv::render::render_component::is_created(), node_buffer_counter, and cgv::render::shader_program::set_uniform().
|
inline |
Definition at line 72 of file a_buffer.h.
|
inline |
Definition at line 74 of file a_buffer.h.
|
inline |
Definition at line 73 of file a_buffer.h.
|
inline |
Definition at line 75 of file a_buffer.h.
void cgv::render::a_buffer::update_defines | ( | shader_define_map & | defines | ) |
update the provided shader defines with respect to a_buffer settings. Call before enabling a program.
Definition at line 63 of file a_buffer.cxx.
|
protected |
Definition at line 40 of file a_buffer.cxx.
|
protected |
Definition at line 36 of file a_buffer.h.
|
protected |
Definition at line 35 of file a_buffer.h.
|
protected |
Depth texture used to emulate depth buffer.
Definition at line 23 of file a_buffer.h.
Referenced by a_buffer(), destruct(), disable(), enable(), and init_frame().
|
protected |
Default texture unit used for depth texture.
Definition at line 29 of file a_buffer.h.
Referenced by a_buffer(), and enable().
unsigned cgv::render::a_buffer::fragments_per_pixel |
to be handled fragments per pixel (changes are applied when in init_frame() function)
Definition at line 49 of file a_buffer.h.
Referenced by a_buffer().
|
protected |
Definition at line 26 of file a_buffer.h.
|
protected |
Definition at line 32 of file a_buffer.h.
|
protected |
Definition at line 27 of file a_buffer.h.
|
protected |
Buffers used to store per pixel frament lists.
Definition at line 25 of file a_buffer.h.
Referenced by a_buffer(), disable(), enable(), and init_frame().
|
protected |
Buffer binding point indices.
Definition at line 31 of file a_buffer.h.
Referenced by a_buffer(), disable(), and enable().
|
protected |
Definition at line 33 of file a_buffer.h.
unsigned cgv::render::a_buffer::nodes_per_pixel |
to be reserved number of fragment nodes per pixel (changes are applied when in init_frame() function)
Definition at line 51 of file a_buffer.h.
Referenced by a_buffer(), enable(), and finish_frame().