Hymn to Beauty
C++ 3D Engine
OpenGLBuffer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Interface/Buffer.hpp"
4#include "../Interface/BufferAllocator.hpp"
5
6#include <glad/glad.h>
7
8namespace Video {
9
11class OpenGLBuffer : public Buffer {
12 public:
14
19
21 ~OpenGLBuffer() final;
22
23 void Reset(BufferUsage bufferUsage, const BufferAllocation& allocation) final;
24 unsigned int GetSize() const final;
25
27
30 GLuint GetBufferID() const;
31
33
36 GLenum GetTarget() const;
37
39
42 uint32_t GetOffset() const;
43
44 private:
45 OpenGLBuffer(const OpenGLBuffer& other) = delete;
46
47 GLenum target;
48 GLuint buffer;
49 uint32_t offset;
50 uint32_t size;
51
52 RawBuffer* rawBuffer = nullptr;
53 bool temporaryAllocation = false;
54
55#ifndef NDEBUG
56 bool mapped = false;
57#endif
58};
59
60}
A buffer containing GPU accessible data.
Definition: Buffer.hpp:8
BufferUsage
How the buffer is going to be used.
Definition: Buffer.hpp:11
BufferUsage bufferUsage
How the buffer will be used.
Definition: Buffer.hpp:54
OpenGL implementation of Buffer.
Definition: OpenGLBuffer.hpp:11
GLenum GetTarget() const
Get the OpenGL target.
Definition: OpenGLBuffer.cpp:41
uint32_t GetOffset() const
Get the offset into the raw buffer.
Definition: OpenGLBuffer.cpp:45
unsigned int GetSize() const final
Get the size of the buffer.
Definition: OpenGLBuffer.cpp:33
~OpenGLBuffer() final
Destructor.
Definition: OpenGLBuffer.cpp:13
OpenGLBuffer(Buffer::BufferUsage bufferUsage, const BufferAllocation &allocation)
Create new OpenGL buffer.
Definition: OpenGLBuffer.cpp:9
GLuint GetBufferID() const
Get the buffer OpenGL ID.
Definition: OpenGLBuffer.cpp:37
void Reset(BufferUsage bufferUsage, const BufferAllocation &allocation) final
Reset the buffer.
Definition: OpenGLBuffer.cpp:22
A large buffer from which buffers are sub-allocated.
Definition: BufferAllocator.hpp:21
Definition: Editor.hpp:18
An allocation.
Definition: BufferAllocator.hpp:36