SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
DebugLineRenderer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Core/OSDef.hpp>
4#include <Math/Vector.hpp>
5#include <Memory/RefPtr.hpp>
7#include <vector>
8
9namespace Sleak {
10
11struct Vertex;
12namespace RenderEngine { class BufferBase; class Shader; }
13
14class Camera;
15
16/// Immediate-mode wireframe line drawing for debug visualization; lines queue up and are flushed once per frame.
17/// @ingroup debug
18class ENGINE_API DebugLineRenderer {
19public:
20 /// Allocates the shared vertex buffer, shader, and constant buffer.
21 static void Initialize();
22 static void Shutdown();
23
24 static void SetEnabled(bool enabled) { s_enabled = enabled; }
25 static bool IsEnabled() { return s_enabled; }
26
27 /// Queues a single line segment for the next Flush.
28 static void DrawLine(const Math::Vector3D& start, const Math::Vector3D& end,
29 float r, float g, float b, float a = 1.0f);
30
31 /// Queues a wireframe box outline.
32 static void DrawAABB(const Physics::AABB& aabb,
33 float r, float g, float b, float a = 1.0f);
34
35 /// Queues a wireframe sphere approximated with segments latitude/longitude rings.
36 static void DrawSphere(const Math::Vector3D& center, float radius,
37 float r, float g, float b, float a = 1.0f,
38 int segments = 16);
39
40 /// Queues a wireframe capsule outline.
41 static void DrawCapsule(const Physics::BoundingCapsule& capsule,
42 float r, float g, float b, float a = 1.0f,
43 int segments = 16);
44
45 /// Uploads all queued lines and draws them in one pass, then clears the queue.
46 static void Flush(Camera* camera);
47
48private:
49 static std::vector<Vertex>* s_vertices;
50 static RefPtr<RenderEngine::BufferBase> s_vertexBuffer;
51 static RefPtr<RenderEngine::Shader> s_shader;
52 static RefPtr<RenderEngine::BufferBase> s_constantBuffer;
53 static bool s_enabled;
54 static bool s_initialized;
55
56 static constexpr uint32_t MAX_VERTICES = 65536;
57};
58
59} // namespace Sleak
static void SetEnabled(bool enabled)
static void Initialize()
Allocates the shared vertex buffer, shader, and constant buffer.
Backend-agnostic GPU buffer: vertex, index, constant, or resource view target.
Backend-agnostic compiled shader program.
Definition Shader.hpp:11
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.
Definition Camera.hpp:10