Line data Source code
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" 22 : #include "renderer/backend/IBuffer.h" 23 : 24 : #if CONFIG2_GLES 25 : #include "external_libraries/opengles2_wrapper.h" 26 : #else 27 : #include <glad/gl.h> 28 : #endif 29 : 30 : #include <cstdint> 31 : #include <memory> 32 : 33 : namespace Renderer 34 : { 35 : 36 : namespace Backend 37 : { 38 : 39 : namespace GL 40 : { 41 : 42 : class CDevice; 43 : 44 : class CBuffer final : public IBuffer 45 : { 46 : public: 47 : ~CBuffer() override; 48 : 49 : IDevice* GetDevice() override; 50 : 51 0 : Type GetType() const override { return m_Type; } 52 0 : uint32_t GetSize() const override { return m_Size; } 53 0 : uint32_t GetUsage() const override { return m_Usage; } 54 : 55 0 : GLuint GetHandle() { return m_Handle; } 56 : 57 : private: 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 : 64 : CBuffer(); 65 : 66 : CDevice* m_Device = nullptr; 67 : Type m_Type = Type::VERTEX; 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