cgv
Loading...
Searching...
No Matches
a_buffer.h
1#pragma once
2
3#include <cgv/render/shader_program.h>
4#include <cgv/render/texture.h>
5#include <cgv_gl/gl/gl.h>
6
7#include "gl/lib_begin.h"
8
9namespace cgv {
10 namespace render {
11
14class CGV_API a_buffer
15{
16 unsigned last_fragments_per_pixel;
17 unsigned last_nodes_per_pixel;
18 shader_define_map last_defines;
19 shader_define_map defines;
20 bool init_frame_called;
21protected:
26 unsigned head_pointer_buffer;
27 unsigned node_buffer;
32 int head_pointers_binding_point;
33 int nodes_binding_point;
34 // GPU objects
35 shader_program clear_ssbo_prog;
36 shader_program a_buffer_prog;
37
38 static void ensure_buffer(GLuint& buffer, GLenum target, GLsizeiptr size, const void* data, GLenum usage = GL_DYNAMIC_DRAW);
39 static void destruct_buffer(GLuint& buffer);
40 void destruct_buffers(context& ctx);
41 void ensure_buffers(context& ctx);
42
43 void update_defines(shader_define_map& defines, bool include_binding_points);
44public:
46 a_buffer(unsigned _fragments_per_pixel = 32, unsigned _nodes_per_pixel = 64, int _depth_tex_unit = 0,
47 int _node_counter_binding_point = 0, int _head_pointers_binding_point = 0, int _nodes_binding_point = 1);
53 bool init(context& ctx);
55 void destruct(context& ctx);
57 void init_frame(context& ctx);
59 void update_defines(shader_define_map& defines);
61
66 bool enable(context& ctx, shader_program& prog, int tex_unit = -1);
68 size_t disable(context& ctx);
70 void finish_frame(context& ctx);
71
72 int& ref_depth_tex_unit() { return depth_tex_unit; }
73 int& ref_node_counter_binding_point () { return node_counter_binding_point ; }
74 int& ref_head_pointers_binding_point() { return head_pointers_binding_point ; }
75 int& ref_nodes_binding_point () { return nodes_binding_point ; }
76};
77 }
78}
79
80#include <cgv/config/lib_end.h>
This class provides a_buffer functionality.
Definition a_buffer.h:15
unsigned node_buffer_counter
Buffers used to store per pixel frament lists.
Definition a_buffer.h:25
unsigned nodes_per_pixel
to be reserved number of fragment nodes per pixel (changes are applied when in init_frame() function)
Definition a_buffer.h:51
unsigned fragments_per_pixel
to be handled fragments per pixel (changes are applied when in init_frame() function)
Definition a_buffer.h:49
texture depth_tex
Depth texture used to emulate depth buffer.
Definition a_buffer.h:23
int node_counter_binding_point
Buffer binding point indices.
Definition a_buffer.h:31
int depth_tex_unit
Default texture unit used for depth texture.
Definition a_buffer.h:29
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
a shader program combines several shader code fragments to a complete definition of the shading pipel...
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
the cgv namespace
Definition print.h:11