galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
ShaderStorageBuffer.cpp
Go to the documentation of this file.
1
7
9
10namespace galaxy
11{
13 : m_id {0}
14 , m_index {index}
15 {
16 glCreateBuffers(1, &m_id);
17 }
18
20 {
21 this->destroy();
22
23 this->m_id = s.m_id;
24 this->m_index = s.m_index;
25
26 s.m_id = 0;
27 }
28
30 {
31 if (this != &s)
32 {
33 this->destroy();
34
35 this->m_id = s.m_id;
36 this->m_index = s.m_index;
37
38 s.m_id = 0;
39 }
40
41 return *this;
42 }
43
48
50 {
51 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, m_index, m_id);
52 }
53
55 {
56 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, m_index, 0);
57 }
58
60 {
61 auto size = 0;
62
63 glGetNamedBufferParameteriv(m_id, GL_BUFFER_SIZE, &size);
64 glNamedBufferData(m_id, size, nullptr, GL_DYNAMIC_DRAW);
65 }
66
68 {
69 if (m_id != 0)
70 {
71 glDeleteBuffers(1, &m_id);
72 m_id = 0;
73 }
74 }
75
76 unsigned int ShaderStorageBuffer::id() const noexcept
77 {
78 return m_id;
79 }
80} // namespace galaxy
void bind() const
Bind buffer.
unsigned int m_id
OpenGL handle.
ShaderStorageBuffer()=delete
Default constructor.
int m_index
Index binding of SSBO in vertex shader.
void clear() const
Clears data from buffer.
ShaderStorageBuffer & operator=(ShaderStorageBuffer &&) noexcept
Move assignment operator.
void unbind() const
Unbind buffer.
unsigned int id() const noexcept
Get OpenGL handle.
Animated.cpp galaxy.
Definition Animated.cpp:16