Pyrogenesis  trunk
DebugRenderer.h
Go to the documentation of this file.
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 
22 #include "ps/CStrIntern.h"
24 
25 #include <unordered_map>
26 #include <vector>
27 
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.
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:
77  const CStrIntern name, const CColor& color, const bool depthTestEnabled = true,
78  const bool wireframe = false);
79 
81  {
85  bool wireframe;
86  };
88  {
89  size_t operator()(const ShaderTechniqueKey& key) const;
90  };
92  {
93  bool operator()(const ShaderTechniqueKey& lhs, const ShaderTechniqueKey& rhs) const;
94  };
95  std::unordered_map<ShaderTechniqueKey, CShaderTechniquePtr, ShaderTechniqueKeyHash, ShaderTechniqueKeyEqual>
97 
99 };
100 
101 #endif // INCLUDED_DEBUGRENDERER
std::unordered_map< ShaderTechniqueKey, CShaderTechniquePtr, ShaderTechniqueKeyHash, ShaderTechniqueKeyEqual > m_ShaderTechniqueMapping
Definition: DebugRenderer.h:96
Definition: Color.h:42
IVertexInputLayout stores precompiled list of vertex attributes.
Definition: IShaderProgram.h:73
Definition: Vector3D.h:30
void DrawBoundingBox(const CBoundingBoxAligned &boundingBox, const CColor &color, bool wireframe=false)
Render the surfaces of the bound box as triangles.
Definition: DebugRenderer.cpp:274
bool wireframe
Definition: DebugRenderer.h:85
void DrawLine(const CVector3D &from, const CVector3D &to, const CColor &color, const float width, const bool depthTestEnabled=true)
Render the line in world space.
Definition: DebugRenderer.cpp:48
Definition: DebugRenderer.h:80
Definition: DebugRenderer.h:91
Definition: DebugRenderer.h:38
Definition: Matrix3D.h:33
Class CBrush: Represents a convex object, supports some CSG operations.
Definition: Brush.h:37
Interned 8-bit strings.
Definition: CStrIntern.h:37
void DrawBrush(const CBrush &brush, const CColor &color, bool wireframe=false)
Render the surfaces of the brush as triangles.
Definition: DebugRenderer.cpp:333
CStrIntern name
Definition: DebugRenderer.h:82
pthread_key_t key
Definition: wpthread.cpp:140
Definition: Camera.h:41
void DrawCircle(const CVector3D &origin, const float radius, const CColor &color)
Render the circle in world space oriented to the view camera.
Definition: DebugRenderer.cpp:121
const CShaderTechniquePtr & GetShaderTechnique(const CStrIntern name, const CColor &color, const bool depthTestEnabled=true, const bool wireframe=false)
Definition: DebugRenderer.cpp:406
void Initialize()
Definition: DebugRenderer.cpp:38
Definition: BoundingBoxAligned.h:33
void DrawCameraFrustum(const CCamera &camera, const CColor &color, int intermediates=0, bool wireframe=false)
Render: Renders the camera&#39;s frustum in world space.
Definition: DebugRenderer.cpp:175
Renderer::Backend::IVertexInputLayout * m_VertexInputLayout
Definition: DebugRenderer.h:98
std::shared_ptr< CShaderTechnique > CShaderTechniquePtr
Definition: ShaderTechniquePtr.h:27
Definition: DebugRenderer.h:87
bool depthTestEnabled
Definition: DebugRenderer.h:84
bool transparent
Definition: DebugRenderer.h:83