SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
OpenGLBuffer.hpp
Go to the documentation of this file.
1#ifndef OPENGLBUFFER_HPP_
2#define OPENGLBUFFER_HPP_
3
5#include <glad/glad.h>
6
7namespace Sleak {
8namespace RenderEngine {
9
10/// OpenGL VBO/EBO/UBO wrapper; target is derived from BufferType at construction.
11class ENGINE_API OpenGLBuffer : public BufferBase {
12public:
13 OpenGLBuffer(uint32_t size, BufferType type);
14 ~OpenGLBuffer() override;
15
16 /// Creates the GL buffer object and uploads the initial payload, if any.
17 bool Initialize(void* data) override;
18 /// Re-uploads the last-mapped/updated data via glBufferSubData.
19 void Update() override;
20 /// Uploads new data, resizing the backing store if it grew.
21 void Update(void* data, size_t size) override;
22 void Cleanup() override;
23
24 /// Maps the buffer for direct CPU writes via glMapBuffer.
25 bool Map() override;
26 void Unmap() override;
27
28 void* GetData() override;
29
30 GLuint GetGLBuffer() const { return m_buffer; }
31 GLenum GetTarget() const { return m_target; }
32
33private:
34 GLuint m_buffer = 0;
35 GLenum m_target = 0;
36 void* m_mappedData = nullptr;
37};
38
39} // namespace RenderEngine
40} // namespace Sleak
41
42#endif // OPENGLBUFFER_HPP_
Backend-agnostic GPU buffer: vertex, index, constant, or resource view target.
void Update() override
Re-uploads the last-mapped/updated data via glBufferSubData.
bool Map() override
Maps the buffer for direct CPU writes via glMapBuffer.
OpenGLBuffer(uint32_t size, BufferType type)
bool Initialize(void *data) override
Creates the GL buffer object and uploads the initial payload, if any.
Backend-facing rendering layer shared by the four graphics backends.
BufferType
GPU buffer usage kind, drives backend binding flags and layout.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10