Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Buffer.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_RENDERER_BACKEND_GL_BUFFER
19#define INCLUDED_RENDERER_BACKEND_GL_BUFFER
20
21#include "lib/config2.h"
23
24#if CONFIG2_GLES
26#else
27#include <glad/gl.h>
28#endif
29
30#include <cstdint>
31#include <memory>
32
33namespace Renderer
34{
35
36namespace Backend
37{
38
39namespace GL
40{
41
42class CDevice;
43
44class CBuffer final : public IBuffer
45{
46public:
47 ~CBuffer() override;
48
49 IDevice* GetDevice() override;
50
51 Type GetType() const override { return m_Type; }
52 uint32_t GetSize() const override { return m_Size; }
53 uint32_t GetUsage() const override { return m_Usage; }
54
55 GLuint GetHandle() { return m_Handle; }
56
57private:
58 friend class CDevice;
59
60 static std::unique_ptr<CBuffer> Create(
61 CDevice* device, const char* name,
62 const Type type, const uint32_t size, const uint32_t usage);
63
65
66 CDevice* m_Device = nullptr;
68 uint32_t m_Size = 0;
69 uint32_t m_Usage = 0;
70
71 GLuint m_Handle = 0;
72};
73
74} // namespace GL
75
76} // namespace Backend
77
78} // namespace Renderer
79
80#endif // INCLUDED_RENDERER_BACKEND_GL_BUFFER
Definition: Buffer.h:45
~CBuffer() override
Definition: Buffer.cpp:87
GLuint m_Handle
Definition: Buffer.h:71
Type GetType() const override
Definition: Buffer.h:51
GLuint GetHandle()
Definition: Buffer.h:55
uint32_t m_Usage
Definition: Buffer.h:69
uint32_t m_Size
Definition: Buffer.h:68
uint32_t GetUsage() const override
Definition: Buffer.h:53
static std::unique_ptr< CBuffer > Create(CDevice *device, const char *name, const Type type, const uint32_t size, const uint32_t usage)
Definition: Buffer.cpp:61
Type m_Type
Definition: Buffer.h:67
IDevice * GetDevice() override
Definition: Buffer.cpp:93
uint32_t GetSize() const override
Definition: Buffer.h:52
CDevice * m_Device
Definition: Buffer.h:66
Definition: Device.h:62
Definition: IBuffer.h:32
Type
Definition: IBuffer.h:35
Definition: IDevice.h:64
Backend
Definition: Backend.h:28
Definition: Canvas2D.h:30