Hymn to Beauty
C++ 3D Engine
OpenGLBufferAllocator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "../Interface/BufferAllocator.hpp"
4
5#include <glad/glad.h>
6
7namespace Video {
8
10class OpenGLRawBuffer : public RawBuffer {
11 public:
13
18 OpenGLRawBuffer(Buffer::BufferUsage bufferUsage, bool temporary, unsigned int size);
19
21 ~OpenGLRawBuffer() final;
22
23 void Write(uint32_t offset, uint32_t size, const void* data) final;
24
26
29 GLuint GetBufferID() const;
30
32
35 GLenum GetTarget() const;
36
37 private:
38 GLenum target;
39 GLuint buffer;
40 uint32_t size;
41};
42
45 public:
47
50 OpenGLBufferAllocator(uint32_t frames);
51
54
55 private:
56 OpenGLBufferAllocator(const OpenGLBufferAllocator& other) = delete;
57
58 uint32_t GetAlignment(Buffer::BufferUsage bufferUsage) final;
59 RawBuffer* Allocate(Buffer::BufferUsage bufferUsage, bool temporary, unsigned int size) final;
60 Buffer* CreateBufferObject(Buffer::BufferUsage bufferUsage, const BufferAllocation& allocation) final;
61
62 uint32_t bufferAlignment;
63};
64
65}
Responsible for allocating buffers.
Definition: BufferAllocator.hpp:51
A buffer containing GPU accessible data.
Definition: Buffer.hpp:8
BufferUsage
How the buffer is going to be used.
Definition: Buffer.hpp:11
OpenGL implementation of BufferAllocator.
Definition: OpenGLBufferAllocator.hpp:44
OpenGLBufferAllocator(uint32_t frames)
Create a new buffer allocator.
Definition: OpenGLBufferAllocator.cpp:65
~OpenGLBufferAllocator() final
Destructor.
Definition: OpenGLBufferAllocator.cpp:71
OpenGL implementation of RawBuffer.
Definition: OpenGLBufferAllocator.hpp:10
~OpenGLRawBuffer() final
Destructor.
Definition: OpenGLBufferAllocator.cpp:43
void Write(uint32_t offset, uint32_t size, const void *data) final
Write data to buffer.
Definition: OpenGLBufferAllocator.cpp:47
GLuint GetBufferID() const
Get the buffer OpenGL ID.
Definition: OpenGLBufferAllocator.cpp:57
GLenum GetTarget() const
Get the OpenGL target.
Definition: OpenGLBufferAllocator.cpp:61
OpenGLRawBuffer(Buffer::BufferUsage bufferUsage, bool temporary, unsigned int size)
Create new raw buffer used to satisfy allocations.
Definition: OpenGLBufferAllocator.cpp:9
A large buffer from which buffers are sub-allocated.
Definition: BufferAllocator.hpp:21
Definition: Editor.hpp:18
An allocation.
Definition: BufferAllocator.hpp:36