LCOV - code coverage report
Current view: top level - source/renderer - DebugRenderer.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 1 1 100.0 %
Date: 2023-01-19 00:18:29 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* Copyright (C) 2023 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_DEBUGRENDERER
      19             : #define INCLUDED_DEBUGRENDERER
      20             : 
      21             : #include "graphics/ShaderTechniquePtr.h"
      22             : #include "ps/CStrIntern.h"
      23             : #include "renderer/backend/IShaderProgram.h"
      24             : 
      25             : #include <unordered_map>
      26             : #include <vector>
      27             : 
      28             : class CBoundingBoxAligned;
      29             : class CBrush;
      30             : class CCamera;
      31             : class CMatrix3D;
      32             : class CVector3D;
      33             : 
      34             : struct CColor;
      35             : 
      36             : // Helper for unoptimized rendering of geometrics primitives. Should not be
      37             : // used for regular passes.
      38          12 : class CDebugRenderer
      39             : {
      40             : public:
      41             :     void Initialize();
      42             : 
      43             :     /**
      44             :      * Render the line in world space.
      45             :      */
      46             :     void DrawLine(const CVector3D& from, const CVector3D& to,
      47             :         const CColor& color, const float width, const bool depthTestEnabled = true);
      48             :     void DrawLine(const std::vector<CVector3D>& line,
      49             :         const CColor& color, const float width, const bool depthTestEnabled = true);
      50             : 
      51             :     /**
      52             :      * Render the circle in world space oriented to the view camera.
      53             :      */
      54             :     void DrawCircle(const CVector3D& origin, const float radius, const CColor& color);
      55             : 
      56             :     /**
      57             :      * Render: Renders the camera's frustum in world space.
      58             :      *
      59             :      * @param intermediates determines how many intermediate distance planes should
      60             :      * be hinted at between the near and far planes
      61             :      */
      62             :     void DrawCameraFrustum(const CCamera& camera, const CColor& color, int intermediates = 0, bool wireframe = false);
      63             : 
      64             :     /**
      65             :      * Render the surfaces of the bound box as triangles.
      66             :      */
      67             :     void DrawBoundingBox(const CBoundingBoxAligned& boundingBox, const CColor& color, bool wireframe = false);
      68             :     void DrawBoundingBox(const CBoundingBoxAligned& boundingBox, const CColor& color, const CMatrix3D& transform, bool wireframe = false);
      69             : 
      70             :     /**
      71             :      * Render the surfaces of the brush as triangles.
      72             :      */
      73             :     void DrawBrush(const CBrush& brush, const CColor& color, bool wireframe = false);
      74             : 
      75             : private:
      76             :     const CShaderTechniquePtr& GetShaderTechnique(
      77             :         const CStrIntern name, const CColor& color, const bool depthTestEnabled = true,
      78             :         const bool wireframe = false);
      79             : 
      80             :     struct ShaderTechniqueKey
      81             :     {
      82             :         CStrIntern name;
      83             :         bool transparent;
      84             :         bool depthTestEnabled;
      85             :         bool wireframe;
      86             :     };
      87             :     struct ShaderTechniqueKeyHash
      88             :     {
      89             :         size_t operator()(const ShaderTechniqueKey& key) const;
      90             :     };
      91             :     struct ShaderTechniqueKeyEqual
      92             :     {
      93             :         bool operator()(const ShaderTechniqueKey& lhs, const ShaderTechniqueKey& rhs) const;
      94             :     };
      95             :     std::unordered_map<ShaderTechniqueKey, CShaderTechniquePtr, ShaderTechniqueKeyHash, ShaderTechniqueKeyEqual>
      96             :         m_ShaderTechniqueMapping;
      97             : 
      98             :     Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr;
      99             : };
     100             : 
     101             : #endif // INCLUDED_DEBUGRENDERER

Generated by: LCOV version 1.13