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

          Line data    Source code
       1             : /* Copyright (C) 2025 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 "Mapping.h"
      21             : 
      22             : #include "lib/config2.h"
      23             : #include "lib/debug.h"
      24             : #include "renderer/backend/CompareOp.h"
      25             : #include "renderer/backend/PipelineState.h"
      26             : 
      27             : namespace Renderer
      28             : {
      29             : 
      30             : namespace Backend
      31             : {
      32             : 
      33             : namespace GL
      34             : {
      35             : 
      36             : namespace Mapping
      37             : {
      38             : 
      39           0 : GLenum FromCompareOp(const CompareOp compareOp)
      40             : {
      41           0 :     GLenum op = GL_NEVER;
      42           0 :     switch (compareOp)
      43             :     {
      44             : #define CASE(NAME, GL_NAME) case CompareOp::NAME: op = GL_NAME; break
      45             :     CASE(NEVER, GL_NEVER);
      46             :     CASE(LESS, GL_LESS);
      47             :     CASE(EQUAL, GL_EQUAL);
      48             :     CASE(LESS_OR_EQUAL, GL_LEQUAL);
      49             :     CASE(GREATER, GL_GREATER);
      50             :     CASE(NOT_EQUAL, GL_NOTEQUAL);
      51             :     CASE(GREATER_OR_EQUAL, GL_GEQUAL);
      52             :     CASE(ALWAYS, GL_ALWAYS);
      53             : #undef CASE
      54             :     }
      55           0 :     return op;
      56             : }
      57             : 
      58           0 : GLenum FromStencilOp(const StencilOp stencilOp)
      59             : {
      60           0 :     GLenum op = GL_KEEP;
      61           0 :     switch (stencilOp)
      62             :     {
      63             : #define CASE(NAME, GL_NAME) case StencilOp::NAME: op = GL_NAME; break
      64             :     CASE(KEEP, GL_KEEP);
      65             :     CASE(ZERO, GL_ZERO);
      66             :     CASE(REPLACE, GL_REPLACE);
      67             :     CASE(INCREMENT_AND_CLAMP, GL_INCR);
      68             :     CASE(DECREMENT_AND_CLAMP, GL_DECR);
      69             :     CASE(INVERT, GL_INVERT);
      70             :     CASE(INCREMENT_AND_WRAP, GL_INCR_WRAP);
      71             :     CASE(DECREMENT_AND_WRAP, GL_DECR_WRAP);
      72             : #undef CASE
      73             :     }
      74           0 :     return op;
      75             : }
      76             : 
      77           0 : GLenum FromBlendFactor(const BlendFactor blendFactor)
      78             : {
      79           0 :     GLenum factor = GL_ZERO;
      80           0 :     switch (blendFactor)
      81             :     {
      82             : #define CASE(NAME) case BlendFactor::NAME: factor = GL_##NAME; break
      83             :     CASE(ZERO);
      84           0 :     CASE(ONE);
      85           0 :     CASE(SRC_COLOR);
      86           0 :     CASE(ONE_MINUS_SRC_COLOR);
      87           0 :     CASE(DST_COLOR);
      88           0 :     CASE(ONE_MINUS_DST_COLOR);
      89           0 :     CASE(SRC_ALPHA);
      90           0 :     CASE(ONE_MINUS_SRC_ALPHA);
      91           0 :     CASE(DST_ALPHA);
      92           0 :     CASE(ONE_MINUS_DST_ALPHA);
      93           0 :     CASE(CONSTANT_COLOR);
      94           0 :     CASE(ONE_MINUS_CONSTANT_COLOR);
      95           0 :     CASE(CONSTANT_ALPHA);
      96           0 :     CASE(ONE_MINUS_CONSTANT_ALPHA);
      97           0 :     CASE(SRC_ALPHA_SATURATE);
      98             : #undef CASE
      99             :     // Dual source blending presents only in GL_VERSION >= 3.3.
     100           0 :     case BlendFactor::SRC1_COLOR:
     101           0 :     case BlendFactor::ONE_MINUS_SRC1_COLOR:
     102           0 :     case BlendFactor::SRC1_ALPHA:
     103           0 :     case BlendFactor::ONE_MINUS_SRC1_ALPHA:
     104           0 :         debug_warn("Unsupported blend factor.");
     105             :         break;
     106             :     }
     107           0 :     return factor;
     108             : }
     109             : 
     110           0 : GLenum FromBlendOp(const BlendOp blendOp)
     111             : {
     112           0 :     GLenum mode = GL_FUNC_ADD;
     113           0 :     switch (blendOp)
     114             :     {
     115             :     case BlendOp::ADD: mode = GL_FUNC_ADD; break;
     116             :     case BlendOp::SUBTRACT: mode = GL_FUNC_SUBTRACT; break;
     117             :     case BlendOp::REVERSE_SUBTRACT: mode = GL_FUNC_REVERSE_SUBTRACT; break;
     118             : #if !CONFIG2_GLES
     119             :     case BlendOp::MIN: mode = GL_MIN; break;
     120             :     case BlendOp::MAX: mode = GL_MAX; break;
     121             : #else
     122             :     case BlendOp::MIN:
     123             :     case BlendOp::MAX:
     124             :         debug_warn("Unsupported blend op.");
     125             :         break;
     126             : #endif
     127           0 :     };
     128           0 :     return mode;
     129             : }
     130             : 
     131             : } // namespace Mapping
     132             : 
     133             : } // namespace GL
     134             : 
     135             : } // namespace Backend
     136             : 
     137             : } // namespace Renderer

Generated by: LCOV version 1.16