Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
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
29class CBrush;
30class CCamera;
31class CMatrix3D;
32class CVector3D;
33
34struct CColor;
35
36// Helper for unoptimized rendering of geometrics primitives. Should not be
37// used for regular passes.
39{
40public:
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
75private:
77 const CStrIntern name, const CColor& color, const bool depthTestEnabled = true,
78 const bool wireframe = false);
79
81 {
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::shared_ptr< CShaderTechnique > CShaderTechniquePtr
Definition: ShaderTechniquePtr.h:28
Definition: BoundingBoxAligned.h:34
Class CBrush: Represents a convex object, supports some CSG operations.
Definition: Brush.h:38
Definition: Camera.h:42
Definition: DebugRenderer.h:39
std::unordered_map< ShaderTechniqueKey, CShaderTechniquePtr, ShaderTechniqueKeyHash, ShaderTechniqueKeyEqual > m_ShaderTechniqueMapping
Definition: DebugRenderer.h:96
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
void Initialize()
Definition: DebugRenderer.cpp:38
Renderer::Backend::IVertexInputLayout * m_VertexInputLayout
Definition: DebugRenderer.h:98
void DrawBrush(const CBrush &brush, const CColor &color, bool wireframe=false)
Render the surfaces of the brush as triangles.
Definition: DebugRenderer.cpp:333
const CShaderTechniquePtr & GetShaderTechnique(const CStrIntern name, const CColor &color, const bool depthTestEnabled=true, const bool wireframe=false)
Definition: DebugRenderer.cpp:406
void DrawCameraFrustum(const CCamera &camera, const CColor &color, int intermediates=0, bool wireframe=false)
Render: Renders the camera's frustum in world space.
Definition: DebugRenderer.cpp:175
void DrawBoundingBox(const CBoundingBoxAligned &boundingBox, const CColor &color, bool wireframe=false)
Render the surfaces of the bound box as triangles.
Definition: DebugRenderer.cpp:274
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
Definition: Matrix3D.h:34
Interned 8-bit strings.
Definition: CStrIntern.h:38
Definition: Vector3D.h:31
IVertexInputLayout stores precompiled list of vertex attributes.
Definition: IShaderProgram.h:74
Definition: Color.h:43
Definition: DebugRenderer.h:92
bool operator()(const ShaderTechniqueKey &lhs, const ShaderTechniqueKey &rhs) const
Definition: DebugRenderer.cpp:397
Definition: DebugRenderer.h:88
size_t operator()(const ShaderTechniqueKey &key) const
Definition: DebugRenderer.cpp:386
Definition: DebugRenderer.h:81
bool transparent
Definition: DebugRenderer.h:83
bool depthTestEnabled
Definition: DebugRenderer.h:84
bool wireframe
Definition: DebugRenderer.h:85
CStrIntern name
Definition: DebugRenderer.h:82
pthread_key_t key
Definition: wpthread.cpp:140