candlewick 0.10.0
A tiny cross-platform renderer based on SDL3
Loading...
Searching...
No Matches
Frustum.h
Go to the documentation of this file.
1#pragma once
2
3#include "../Device.h"
4#include "../Collision.h"
6#include "../math_types.h"
7
8#include <entt/entity/registry.hpp>
9#include <SDL3/SDL_gpu.h>
10#include <variant>
11
12namespace candlewick {
13namespace frustum_debug {
14
16
17 void renderFrustum(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass,
18 const Camera &mainCamera, const Camera &otherCam,
19 const Float4 &color = 0x40FF00CC_rgbaf);
20
21 void renderAABB(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass,
22 const Camera &camera, const AABB &aabb,
23 const Float4 &color = 0x00BFFFff_rgbaf);
24
25 void renderOBB(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass,
26 const Camera &camera, const coal::OBB &obb,
27 const Float4 &color = 0x00BFFFff_rgbaf);
28
29 void renderFrustum(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass,
30 const Mat4f &invProj, const Mat4f &mvp,
31 const Float3 eyePos, const Float4 &color);
32
33} // namespace frustum_debug
34
39
41 std::variant<AABB, coal::OBB> bounds;
42 GpuVec4 color = 0xA03232FF_rgbaf;
43};
44
46 const RenderContext &renderer;
47 const Device &device;
48 GraphicsPipeline pipeline;
49 entt::registry &_registry;
50
51public:
53 const RenderContext &renderer);
54
55 entt::registry &registry() { return _registry; }
56 const entt::registry &registry() const { return _registry; }
57
58 std::tuple<entt::entity, DebugFrustumComponent &>
59 addFrustum(const Camera &otherCam, Float4 color = 0x00BFFFff_rgbaf) {
60 auto entity = registry().create();
61 auto &item =
62 registry().emplace<DebugFrustumComponent>(entity, &otherCam, color);
63 return {entity, item};
64 }
65
66 template <typename BoundsType>
67 std::tuple<entt::entity, DebugBoundsComponent &>
68 addBounds(const BoundsType &bounds) {
69 auto entity = registry().create();
70 auto &item = registry().emplace<DebugBoundsComponent>(entity, bounds);
71 return {entity, item};
72 }
73
74 void render(CommandBuffer &cmdBuf, const Camera &camera);
75
76 void release() noexcept { pipeline.release(); }
77
78 void update() {}
79};
80static_assert(Scene<FrustumBoundsDebugSystem>);
81
82} // namespace candlewick
Definition CommandBuffer.h:16
std::tuple< entt::entity, DebugFrustumComponent & > addFrustum(const Camera &otherCam, Float4 color=0x00BFFFff_rgbaf)
Definition Frustum.h:59
FrustumBoundsDebugSystem(entt::registry &registry, const RenderContext &renderer)
void update()
Definition Frustum.h:78
std::tuple< entt::entity, DebugBoundsComponent & > addBounds(const BoundsType &bounds)
Definition Frustum.h:68
void render(CommandBuffer &cmdBuf, const Camera &camera)
const entt::registry & registry() const
Definition Frustum.h:56
void release() noexcept
Definition Frustum.h:76
entt::registry & registry()
Definition Frustum.h:55
Class representing a graphics pipeline.
Definition GraphicsPipeline.h:15
Definition Frustum.h:13
void renderFrustum(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass, const Camera &mainCamera, const Camera &otherCam, const Float4 &color=0x40FF00CC_rgbaf)
void renderOBB(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass, const Camera &camera, const coal::OBB &obb, const Float4 &color=0x00BFFFff_rgbaf)
void renderAABB(CommandBuffer &cmdBuf, SDL_GPURenderPass *render_pass, const Camera &camera, const AABB &aabb, const Float4 &color=0x00BFFFff_rgbaf)
GraphicsPipeline createFrustumDebugPipeline(const RenderContext &renderer)
Definition Camera.h:8
Eigen::Vector3f Float3
Definition math_types.h:8
Eigen::Vector4f Float4
Definition math_types.h:9
Eigen::Matrix< float, 4, 1, Eigen::DontAlign > GpuVec4
Definition math_types.h:19
Eigen::Matrix4f Mat4f
Definition math_types.h:11
The main way of using a camera to render things.
Definition Camera.h:19
Definition Frustum.h:40
GpuVec4 color
Definition Frustum.h:42
std::variant< AABB, coal::OBB > bounds
Definition Frustum.h:41
Definition Frustum.h:35
Camera const * otherCam
Definition Frustum.h:36
GpuVec4 color
Definition Frustum.h:37
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17
The RenderContext class provides a rendering context for a graphical application.
Definition RenderContext.h:36