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 shader_compile_options prog_options;
21 shader_compile_options last_prog_options;
22 bool init_frame_called;
23protected:
28 unsigned head_pointer_buffer;
29 unsigned node_buffer;
34 int head_pointers_binding_point;
35 int nodes_binding_point;
36 // GPU objects
37 shader_program clear_ssbo_prog;
38 shader_program a_buffer_prog;
39
40 static void ensure_buffer(GLuint& buffer, GLenum target, GLsizeiptr size, const void* data, GLenum usage = GL_DYNAMIC_DRAW);
41 static void destruct_buffer(GLuint& buffer);
42 void destruct_buffers(context& ctx);
43 void ensure_buffers(context& ctx);
44
45 void update_shader_program_options(shader_compile_options& options, bool include_binding_points);
46public:
48 a_buffer(unsigned _fragments_per_pixel = 32, unsigned _nodes_per_pixel = 64, int _depth_tex_unit = 0,
49 int _node_counter_binding_point = 0, int _head_pointers_binding_point = 0, int _nodes_binding_point = 1);
55 bool init(context& ctx);
57 void destruct(context& ctx);
59 void init_frame(context& ctx);
61 void update_shader_program_options(shader_compile_options& options);
63
68 bool enable(context& ctx, shader_program& prog, int tex_unit = -1);
70 size_t disable(context& ctx);
72 void finish_frame(context& ctx);
73
74 int& ref_depth_tex_unit() { return depth_tex_unit; }
75 int& ref_node_counter_binding_point () { return node_counter_binding_point ; }
76 int& ref_head_pointers_binding_point() { return head_pointers_binding_point ; }
77 int& ref_nodes_binding_point () { return nodes_binding_point ; }
78};
79 }
80}
81
82#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:27
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:53
unsigned fragments_per_pixel
to be handled fragments per pixel (changes are applied when in init_frame() function)
Definition a_buffer.h:51
texture depth_tex
Depth texture used to emulate depth buffer.
Definition a_buffer.h:25
int node_counter_binding_point
Buffer binding point indices.
Definition a_buffer.h:33
int depth_tex_unit
Default texture unit used for depth texture.
Definition a_buffer.h:31
base class for all drawables, which is independent of the used rendering API.
Definition context.h:627
Stores preprocessor options used for conditionally compiling shader programs.
Definition shader_code.h:73
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
the cgv namespace
Definition print.h:11