LCOV - code coverage report
Current view: top level - source/graphics - Material.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 13 28 46.4 %
Date: 2026-12-03 01:19:39 Functions: 4 8 50.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             : #include "precompiled.h"
      19             : 
      20             : #include "Material.h"
      21             : 
      22             : #include "ps/CStrInternStatic.h"
      23             : 
      24             : #include <utility>
      25             : 
      26             : class CVector4D;
      27             : 
      28           3 : CMaterial::CMaterial() :
      29           3 :     m_AlphaBlending(false)
      30             : {
      31           3 : }
      32             : 
      33          30 : const CMaterial::Shader& CMaterial::GetShader(const Pass pass) const
      34             : {
      35          30 :     ENSURE(pass < Pass::COUNT);
      36          30 :     return m_Shaders[static_cast<uint8_t>(pass)];
      37             : }
      38             : 
      39           0 : void CMaterial::SetShader(const Pass pass, Shader shaderEffect)
      40             : {
      41           0 :     ENSURE(pass < Pass::COUNT);
      42           0 :     m_Shaders[static_cast<uint8_t>(pass)] = std::move(shaderEffect);
      43           0 : }
      44             : 
      45          15 : void CMaterial::AddShaderDefine(const Pass pass, CStrIntern key, CStrIntern value)
      46             : {
      47          15 :     ENSURE(pass < Pass::COUNT);
      48          15 :     m_Shaders[static_cast<uint8_t>(pass)].defines.Add(key, value);
      49          15 : }
      50             : 
      51           1 : void CMaterial::AddStaticUniform(const char* key, const CVector4D& value)
      52             : {
      53           1 :     m_StaticUniforms.Add(key, value);
      54           1 : }
      55             : 
      56           0 : void CMaterial::AddSampler(const TextureSampler& texture)
      57             : {
      58           0 :     m_Samplers.push_back(texture);
      59           0 :     if (texture.Name == str_baseTex)
      60           0 :         m_DiffuseTexture = texture.Sampler;
      61           0 : }
      62             : 
      63           0 : void CMaterial::AddRenderQuery(const char* key)
      64             : {
      65           0 :     m_RenderQueries.Add(key);
      66           0 : }
      67             : 
      68           0 : void CMaterial::AddRequiredSampler(RequiredSampler sampler)
      69             : {
      70           0 :     m_RequiredSamplers.emplace_back(std::move(sampler));
      71           0 : }

Generated by: LCOV version 1.16