Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
OpenGLBuffer.hpp
1/*
2Copyright (C) 2018,2019,2021,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_OPENGLBUFFER_HPP
17#define AEONGAMES_OPENGLBUFFER_HPP
18#include <cstddef>
19#include "aeongames/Buffer.hpp"
20#include "OpenGLFunctions.hpp"
21
22namespace AeonGames
23{
24 class OpenGLRenderer;
26 class OpenGLBuffer : public Buffer
27 {
28 public:
29 OpenGLBuffer ();
31 OpenGLBuffer ( const GLsizei aSize, const GLenum aUsage, const void *aData = nullptr );
33 OpenGLBuffer ( OpenGLBuffer&& aOpenGLBuffer );
34 OpenGLBuffer ( const OpenGLBuffer& aOpenGLBuffer ) = delete;
35 OpenGLBuffer& operator= ( const OpenGLBuffer& aOpenGLBuffer ) = delete;
36 OpenGLBuffer& operator= ( OpenGLBuffer&& aOpenGLBuffer ) = delete;
37 ~OpenGLBuffer();
38
40 void Initialize ( const GLsizei aSize, const GLenum aUsage, const void *aData = nullptr );
42 void Finalize();
45 void WriteMemory ( const size_t aOffset, const size_t aSize, const void *aData = nullptr ) const final;
46 void* Map ( const size_t aOffset, size_t aSize ) const final;
47 void Unmap() const final;
48 size_t GetSize() const final;
51 void* Map ( const GLbitfield aAccess ) const;
53 void* MapRange ( const GLintptr aOffset, const GLsizeiptr aSize, const GLbitfield aAccess ) const;
55 GLuint GetBufferId() const;
56 private:
57 void Initialize ( const void *aData );
58 GLsizei mSize{};
59 GLenum mUsage{};
60 GLuint mBuffer{};
61 };
62}
63#endif
Abstract interface for GPU/memory buffer operations.
Definition Buffer.hpp:24
void * MapRange(const GLintptr aOffset, const GLsizeiptr aSize, const GLbitfield aAccess) const
Map a sub-range of the buffer.
void Unmap() const final
Unmap a previously mapped buffer region.
void WriteMemory(const size_t aOffset, const size_t aSize, const void *aData=nullptr) const final
Write data into the buffer at a given offset.
GLuint GetBufferId() const
Get the OpenGL buffer object identifier.
size_t GetSize() const final
Get the total size of the buffer in bytes.
void Initialize(const GLsizei aSize, const GLenum aUsage, const void *aData=nullptr)
Initialize the buffer with the given size, usage, and optional data.
void * Map(const size_t aOffset, size_t aSize) const final
Map a region of the buffer into CPU-accessible memory.
void Finalize()
Release the buffer resources.
OpenGL rendering backend implementing the Renderer interface.
<- This is here just for the literals
Definition AABB.hpp:31