LCOV - code coverage report
Current view: top level - source/renderer/backend/gl - Texture.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 7 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 6 0.0 %

          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_TEXTURE
      19             : #define INCLUDED_RENDERER_BACKEND_GL_TEXTURE
      20             : 
      21             : #include "lib/config2.h"
      22             : #include "renderer/backend/Format.h"
      23             : #include "renderer/backend/ITexture.h"
      24             : 
      25             : #if CONFIG2_GLES
      26             : #include "external_libraries/opengles2_wrapper.h"
      27             : #else
      28             : #include <glad/gl.h>
      29             : #endif
      30             : 
      31             : #include <cstdint>
      32             : #include <memory>
      33             : 
      34             : namespace Renderer::Backend::Sampler { struct Desc; }
      35             : 
      36             : namespace Renderer
      37             : {
      38             : 
      39             : namespace Backend
      40             : {
      41             : 
      42             : namespace GL
      43             : {
      44             : 
      45             : class CDevice;
      46             : 
      47             : /**
      48             :  * Represents a low-level GL texture, encapsulates all properties initialization.
      49             :  */
      50             : class CTexture final : public ITexture
      51             : {
      52             : public:
      53             :     ~CTexture() override;
      54             : 
      55             :     IDevice* GetDevice() override;
      56             : 
      57           0 :     Type GetType() const override { return m_Type; }
      58           0 :     uint32_t GetUsage() const override { return m_Usage; }
      59           0 :     Format GetFormat() const override { return m_Format; }
      60             : 
      61           0 :     uint32_t GetWidth() const override { return m_Width; }
      62           0 :     uint32_t GetHeight() const override { return m_Height; }
      63           0 :     uint32_t GetMIPLevelCount() const override { return m_MIPLevelCount; }
      64             : 
      65           0 :     GLuint GetHandle() const { return m_Handle; }
      66             : 
      67             : private:
      68             :     friend class CDevice;
      69             : 
      70             :     CTexture();
      71             : 
      72             :     CDevice* m_Device = nullptr;
      73             : 
      74             :     // GL before 3.3 doesn't support sampler objects, so each texture should have
      75             :     // an own default sampler.
      76             :     static std::unique_ptr<CTexture> Create(
      77             :         CDevice* device, const char* name, const Type type, const uint32_t usage,
      78             :         const Format format, const uint32_t width, const uint32_t height,
      79             :         const Sampler::Desc& defaultSamplerDesc, const uint32_t MIPLevelCount, const uint32_t sampleCount);
      80             : 
      81             :     GLuint m_Handle = 0;
      82             : 
      83             :     Type m_Type = Type::TEXTURE_2D;
      84             :     uint32_t m_Usage = 0;
      85             :     Format m_Format = Format::UNDEFINED;
      86             :     uint32_t m_Width = 0;
      87             :     uint32_t m_Height = 0;
      88             :     uint32_t m_MIPLevelCount = 0;
      89             : };
      90             : 
      91             : } // namespace GL
      92             : 
      93             : } // namespace Backend
      94             : 
      95             : } // namespace Renderer
      96             : 
      97             : #endif // INCLUDED_RENDERER_BACKEND_GL_TEXTURE

Generated by: LCOV version 1.16