Plasma Engine  2.0
Loading...
Searching...
No Matches
DearImguiRenderer.h
1#pragma once
2
3#ifdef BUILDSYSTEM_ENABLE_IMGUI_SUPPORT
4
5# include <Core/ResourceManager/ResourceHandle.h>
6# include <Foundation/Math/Rect.h>
7# include <GameEngine/GameEngineDLL.h>
8# include <Imgui/imgui.h>
9# include <RendererCore/Meshes/MeshBufferResource.h>
10# include <RendererCore/Pipeline/Extractor.h>
11# include <RendererCore/Pipeline/RenderData.h>
12# include <RendererCore/Pipeline/Renderer.h>
13
16
17struct alignas(16) plImguiVertex
18{
19 PL_DECLARE_POD_TYPE();
20
21 plVec3 m_Position;
22 plVec2 m_TexCoord;
23 plColorLinearUB m_Color;
24};
25
26struct plImguiBatch
27{
28 PL_DECLARE_POD_TYPE();
29
30 plRectU32 m_ScissorRect;
31 plUInt16 m_uiTextureID;
32 plUInt16 m_uiVertexCount;
33};
34
35class PL_GAMEENGINE_DLL plImguiRenderData : public plRenderData
36{
37 PL_ADD_DYNAMIC_REFLECTION(plImguiRenderData, plRenderData);
38
39public:
41 plArrayPtr<ImDrawIdx> m_Indices;
43};
44
45class PL_GAMEENGINE_DLL plImguiExtractor : public plExtractor
46{
47 PL_ADD_DYNAMIC_REFLECTION(plImguiExtractor, plExtractor);
48
49public:
50 plImguiExtractor(const char* szName = "ImguiExtractor");
51
52 virtual void Extract(
53 const plView& view, const plDynamicArray<const plGameObject*>& visibleObjects, plExtractedRenderData& ref_extractedRenderData) override;
54 virtual plResult Serialize(plStreamWriter& inout_stream) const override;
55 virtual plResult Deserialize(plStreamReader& inout_stream) override;
56};
57
58class PL_GAMEENGINE_DLL plImguiRenderer : public plRenderer
59{
60 PL_ADD_DYNAMIC_REFLECTION(plImguiRenderer, plRenderer);
61 PL_DISALLOW_COPY_AND_ASSIGN(plImguiRenderer);
62
63public:
64 plImguiRenderer();
65 ~plImguiRenderer();
66
67 virtual void GetSupportedRenderDataTypes(plHybridArray<const plRTTI*, 8>& ref_types) const override;
68 virtual void GetSupportedRenderDataCategories(plHybridArray<plRenderData::Category, 8>& ref_categories) const override;
69 virtual void RenderBatch(
70 const plRenderViewContext& renderContext, const plRenderPipelinePass* pPass, const plRenderDataBatch& batch) const override;
71
72protected:
73 void SetupRenderer();
74
75 static constexpr plUInt32 s_uiVertexBufferSize = 10000;
76 static constexpr plUInt32 s_uiIndexBufferSize = s_uiVertexBufferSize * 2;
77
78 plShaderResourceHandle m_hShader;
79 plGALBufferHandle m_hVertexBuffer;
80 plGALBufferHandle m_hIndexBuffer;
81 plVertexDeclarationInfo m_VertexDeclarationInfo;
82};
83
84#endif
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition Color8UNorm.h:61
Definition DynamicArray.h:81
Definition ExtractedRenderData.h:10
Definition Extractor.h:9
Definition RendererFoundationDLL.h:418
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition RenderDataBatch.h:6
Base class for all render data. Render data must contain all information that is needed to render the...
Definition RenderData.h:14
Definition RenderPipelinePass.h:26
This is the base class for types that handle rendering of different object types.
Definition Renderer.h:9
Interface for binary in (read) streams.
Definition Stream.h:22
Interface for binary out (write) streams.
Definition Stream.h:107
Encapsulates a view on the given world through the given camera and rendered with the specified Rende...
Definition View.h:21
Definition Declarations.h:51
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
Definition MeshBufferResource.h:24