2023-01-06 01:39:25 +01:00
|
|
|
/* Copyright (C) 2023 Wildfire Games.
|
2023-12-03 01:30:12 +01:00
|
|
|
* This file is part of 0 A.D.
|
2021-04-15 20:07:01 +02:00
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2021-04-15 20:07:01 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2021-04-15 20:07:01 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-03 01:30:12 +01:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2021-04-15 20:07:01 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_DEBUGRENDERER
|
|
|
|
#define INCLUDED_DEBUGRENDERER
|
|
|
|
|
2022-12-31 19:29:44 +01:00
|
|
|
#include "graphics/ShaderTechniquePtr.h"
|
|
|
|
#include "ps/CStrIntern.h"
|
2023-01-06 01:39:25 +01:00
|
|
|
#include "renderer/backend/IShaderProgram.h"
|
2022-12-31 19:29:44 +01:00
|
|
|
|
|
|
|
#include <unordered_map>
|
2021-04-25 22:48:44 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2021-04-15 20:07:01 +02:00
|
|
|
class CBoundingBoxAligned;
|
|
|
|
class CBrush;
|
|
|
|
class CCamera;
|
2021-04-27 21:23:37 +02:00
|
|
|
class CMatrix3D;
|
2021-04-16 00:51:25 +02:00
|
|
|
class CVector3D;
|
|
|
|
|
|
|
|
struct CColor;
|
2021-04-15 20:07:01 +02:00
|
|
|
|
|
|
|
// Helper for unoptimized rendering of geometrics primitives. Should not be
|
|
|
|
// used for regular passes.
|
|
|
|
class CDebugRenderer
|
|
|
|
{
|
|
|
|
public:
|
2023-01-06 01:39:25 +01:00
|
|
|
void Initialize();
|
|
|
|
|
2021-04-16 00:51:25 +02:00
|
|
|
/**
|
|
|
|
* Render the line in world space.
|
|
|
|
*/
|
2022-02-01 17:38:55 +01:00
|
|
|
void DrawLine(const CVector3D& from, const CVector3D& to,
|
|
|
|
const CColor& color, const float width, const bool depthTestEnabled = true);
|
|
|
|
void DrawLine(const std::vector<CVector3D>& line,
|
|
|
|
const CColor& color, const float width, const bool depthTestEnabled = true);
|
2021-04-16 00:51:25 +02:00
|
|
|
|
2021-04-25 23:55:19 +02:00
|
|
|
/**
|
|
|
|
* Render the circle in world space oriented to the view camera.
|
|
|
|
*/
|
|
|
|
void DrawCircle(const CVector3D& origin, const float radius, const CColor& color);
|
|
|
|
|
2021-04-15 20:07:01 +02:00
|
|
|
/**
|
|
|
|
* Render: Renders the camera's frustum in world space.
|
|
|
|
*
|
|
|
|
* @param intermediates determines how many intermediate distance planes should
|
|
|
|
* be hinted at between the near and far planes
|
|
|
|
*/
|
2022-02-25 23:05:06 +01:00
|
|
|
void DrawCameraFrustum(const CCamera& camera, const CColor& color, int intermediates = 0, bool wireframe = false);
|
2021-04-15 20:07:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the surfaces of the bound box as triangles.
|
|
|
|
*/
|
2022-02-26 01:37:27 +01:00
|
|
|
void DrawBoundingBox(const CBoundingBoxAligned& boundingBox, const CColor& color, bool wireframe = false);
|
|
|
|
void DrawBoundingBox(const CBoundingBoxAligned& boundingBox, const CColor& color, const CMatrix3D& transform, bool wireframe = false);
|
2021-04-15 20:07:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the surfaces of the brush as triangles.
|
|
|
|
*/
|
2022-02-26 01:37:27 +01:00
|
|
|
void DrawBrush(const CBrush& brush, const CColor& color, bool wireframe = false);
|
2022-12-31 19:29:44 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
const CShaderTechniquePtr& GetShaderTechnique(
|
|
|
|
const CStrIntern name, const CColor& color, const bool depthTestEnabled = true,
|
|
|
|
const bool wireframe = false);
|
|
|
|
|
|
|
|
struct ShaderTechniqueKey
|
|
|
|
{
|
|
|
|
CStrIntern name;
|
|
|
|
bool transparent;
|
|
|
|
bool depthTestEnabled;
|
|
|
|
bool wireframe;
|
|
|
|
};
|
|
|
|
struct ShaderTechniqueKeyHash
|
|
|
|
{
|
|
|
|
size_t operator()(const ShaderTechniqueKey& key) const;
|
|
|
|
};
|
|
|
|
struct ShaderTechniqueKeyEqual
|
|
|
|
{
|
|
|
|
bool operator()(const ShaderTechniqueKey& lhs, const ShaderTechniqueKey& rhs) const;
|
|
|
|
};
|
|
|
|
std::unordered_map<ShaderTechniqueKey, CShaderTechniquePtr, ShaderTechniqueKeyHash, ShaderTechniqueKeyEqual>
|
|
|
|
m_ShaderTechniqueMapping;
|
2023-01-06 01:39:25 +01:00
|
|
|
|
|
|
|
Renderer::Backend::IVertexInputLayout* m_VertexInputLayout = nullptr;
|
2021-04-15 20:07:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDED_DEBUGRENDERER
|