#include <gl_buffer.h>
Constant (uniform) buffer class.
Definition at line 17 of file gl_buffer.h.
◆ gl_constant_buffer() [1/2]
scl::gl_constant_buffer::gl_constant_buffer |
( |
u32 |
Size | ) |
|
- Constant (uniform) empty buffer constructor.
- Parameters
-
BindingPoint | - shader_props binding point of buffer. |
Size | - buffer data size. |
Definition at line 12 of file gl_buffer.cpp.
13{
14 this->Size = Size;
15
16 glGenBuffers(1, &Id);
17 glBindBuffer(GL_UNIFORM_BUFFER, Id);
18 glBufferData(GL_UNIFORM_BUFFER, Size, nullptr, GL_STATIC_DRAW);
19 glBindBuffer(GL_UNIFORM_BUFFER, 0);
20
21 SCL_CORE_SUCCES(
"OpenGL Constant buffer with id {} and size {} created.", Id, Size);
22}
#define SCL_CORE_SUCCES(...)
◆ gl_constant_buffer() [2/2]
scl::gl_constant_buffer::gl_constant_buffer |
( |
const void * |
Data, |
|
|
u32 |
Size |
|
) |
| |
- Constant (uniform) buffer filled with data constructor.
- Parameters
-
BindingPoint | - shader_props binding point of buffer. |
Data | - buffer data pointer. |
Size | - buffer data size. |
Definition at line 24 of file gl_buffer.cpp.
25{
26 this->Size = Size;
27
28 glGenBuffers(1, &Id);
29 glBindBuffer(GL_UNIFORM_BUFFER, Id);
30 glBufferData(GL_UNIFORM_BUFFER, Size, Data, GL_STATIC_DRAW);
31 glBindBuffer(GL_UNIFORM_BUFFER, 0);
32
33 SCL_CORE_SUCCES(
"OpenGL Constant buffer with id {} and size {} created.", Id, Size);
34}
◆ ~gl_constant_buffer()
scl::gl_constant_buffer::~gl_constant_buffer |
( |
| ) |
|
|
override |
Constant buffer default destructor.
Definition at line 36 of file gl_buffer.cpp.
◆ Bind()
void scl::gl_constant_buffer::Bind |
( |
u32 |
BindingPoint | ) |
const |
|
overridevirtual |
- Bind buffer to current render stage function.
- Parameters
-
- Returns
- None.
Implements scl::constant_buffer.
Definition at line 41 of file gl_buffer.cpp.
42{
43 this->BindingPoint = BindingPoint;
44 if (Id != 0) glBindBufferBase(GL_UNIFORM_BUFFER, BindingPoint, Id);
45}
◆ Free()
void scl::gl_constant_buffer::Free |
( |
| ) |
|
|
overridevirtual |
- Clear buffer from GPU memory function.
- Parameters
-
- Returns
- None.
Implements scl::constant_buffer.
Definition at line 65 of file gl_buffer.cpp.
66{
67 if (Id != 0)
68 {
69 glDeleteBuffers(1, &Id);
70
71 SCL_CORE_INFO(
"OpenGL Constant buffer with id {} freed.", Id);
72 Id = 0, BindingPoint = 0, Size = 0;
73 }
74}
#define SCL_CORE_INFO(...)
◆ GetHandle()
render_primitive::handle scl::gl_constant_buffer::GetHandle |
( |
| ) |
const |
|
inlineoverride |
Backend api render primitive hadnle getter function.
Definition at line 26 of file gl_buffer.h.
◆ Unbind()
void scl::gl_constant_buffer::Unbind |
( |
| ) |
const |
|
overridevirtual |
- Unbind buffer from current render stage function.
- Parameters
-
- Returns
- None.
Implements scl::constant_buffer.
Definition at line 47 of file gl_buffer.cpp.
48{
49 glBindBufferBase(GL_UNIFORM_BUFFER, BindingPoint, 0);
50 this->BindingPoint = 0;
51}
◆ Update()
void scl::gl_constant_buffer::Update |
( |
void * |
Data, |
|
|
u32 |
Size |
|
) |
| |
|
overridevirtual |
- Update buffer data function.
- Parameters
-
Data | - buffer data pointer. |
Size | - buffer data size. |
- Returns
- None.
Implements scl::constant_buffer.
Definition at line 53 of file gl_buffer.cpp.
54{
55 if (Id != 0)
56 {
57 SCL_CORE_ASSERT(this->Size == Size,
"Constant buffer size can't be changed.");
58
59 glBindBuffer(GL_UNIFORM_BUFFER, Id);
60 glBufferSubData(GL_UNIFORM_BUFFER, 0, Size, Data);
61 glBindBuffer(GL_UNIFORM_BUFFER, 0);
62 }
63}
#define SCL_CORE_ASSERT(expr,...)
The documentation for this class was generated from the following files: