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/render/vertex_buffer.h>
6#include <cgv_gl/gl/gl.h>
7
8#include "gl/lib_begin.h"
9
10namespace cgv {
11 namespace render {
12
15class CGV_API a_buffer
16{
17 shader_compile_options prog_options;
18 shader_compile_options last_prog_options;
19 bool init_frame_called;
20protected:
31 int head_pointers_binding_point;
32 int nodes_binding_point;
33 // GPU objects
34 shader_program clear_ssbo_prog;
35 shader_program a_buffer_prog;
36
37 void ensure_buffers(context& ctx);
38
39 void update_shader_program_options(shader_compile_options& options, bool include_binding_points);
40public:
42 a_buffer(unsigned _fragments_per_pixel = 32, unsigned _nodes_per_pixel = 64, int _depth_tex_unit = 0,
43 int _node_counter_binding_point = 0, int _head_pointers_binding_point = 0, int _nodes_binding_point = 1);
49 bool init(context& ctx);
51 void destruct(context& ctx);
53 void init_frame(context& ctx);
55 void update_shader_program_options(shader_compile_options& options);
57
62 bool enable(context& ctx, shader_program& prog, int tex_unit = -1);
64 void disable(context& ctx, size_t* out_node_count = nullptr);
66 void finish_frame(context& ctx);
67
68 int& ref_depth_tex_unit() { return depth_tex_unit; }
69 int& ref_node_counter_binding_point () { return node_counter_binding_point ; }
70 int& ref_head_pointers_binding_point() { return head_pointers_binding_point ; }
71 int& ref_nodes_binding_point () { return nodes_binding_point ; }
72};
73 }
74}
75
76#include <cgv/config/lib_end.h>
This class provides a_buffer functionality.
Definition a_buffer.h:16
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:47
unsigned fragments_per_pixel
to be handled fragments per pixel (changes are applied when in init_frame() function)
Definition a_buffer.h:45
texture depth_tex
Depth texture used to emulate depth buffer.
Definition a_buffer.h:22
int node_counter_binding_point
Buffer binding point indices.
Definition a_buffer.h:30
int depth_tex_unit
Default texture unit used for depth texture.
Definition a_buffer.h:28
base class for all drawables, which is independent of the used rendering API.
Definition context.h:672
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
a vertex buffer is an unstructured memory block on the GPU.
@ VBT_ATOMIC_COUNTER
The buffer contains atomic counter and will be bound to GL_ATOMIC_COUNTER_BUFFER.
Definition context.h:478
@ VBT_STORAGE
The buffer contains arbitrary data and will be bound to GL_SHADER_STORAGE_BUFFER.
Definition context.h:477
the cgv namespace
Definition print.h:11