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: 1 56 1.8 %
Date: 2023-01-19 00:18:29 Functions: 2 6 33.3 %

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

Generated by: LCOV version 1.13