ezEngine  Milestone 9
DearImguiRenderer.h
1 #pragma once
2 
3 #include <GameEngine/GameEngineDLL.h>
4 #include <RendererCore/Pipeline/Declarations.h>
5 #include <Core/ResourceManager/ResourceHandle.h>
6 #include <RendererCore/Pipeline/RenderData.h>
7 #include <RendererCore/Pipeline/Extractor.h>
8 #include <RendererCore/Meshes/MeshBufferResource.h>
9 #include <Foundation/Math/Rect.h>
10 #include <ThirdParty/Imgui/imgui.h>
11 
12 class ezRenderDataBatch;
14 
15 struct EZ_ALIGN_16(ezImguiVertex)
16 {
18 
19  ezVec3 m_Position;
20  ezVec2 m_TexCoord;
21  ezColorLinearUB m_Color;
22 };
23 
25 {
27 
28  ezRectU32 m_ScissorRect;
29  ezUInt16 m_uiTextureID;
30  ezUInt16 m_uiVertexCount;
31 };
32 
33 class EZ_GAMEENGINE_DLL ezImguiRenderData : public ezRenderData
34 {
35  EZ_ADD_DYNAMIC_REFLECTION(ezImguiRenderData, ezRenderData);
36 
37 public:
38 
39  ezArrayPtr<ezImguiVertex> m_Vertices;
40  ezArrayPtr<ImDrawIdx> m_Indices;
41  ezArrayPtr<ezImguiBatch> m_Batches;
42 };
43 
44 class EZ_GAMEENGINE_DLL ezImguiExtractor : public ezExtractor
45 {
46  EZ_ADD_DYNAMIC_REFLECTION(ezImguiExtractor, ezExtractor);
47 public:
48  ezImguiExtractor(const char* szName = "ImguiExtractor");
49 
50  virtual void Extract(const ezView& view, const ezDynamicArray<const ezGameObject*>& visibleObjects,
51  ezExtractedRenderData& extractedRenderData) override;
52 };
53 
54 class EZ_GAMEENGINE_DLL ezImguiRenderer : public ezRenderer
55 {
56  EZ_ADD_DYNAMIC_REFLECTION(ezImguiRenderer, ezRenderer);
57  EZ_DISALLOW_COPY_AND_ASSIGN(ezImguiRenderer);
58 
59 public:
61  ~ezImguiRenderer();
62 
63  virtual void GetSupportedRenderDataTypes(ezHybridArray<const ezRTTI*, 8>& types) override;
64  virtual void RenderBatch(const ezRenderViewContext& renderContext, ezRenderPipelinePass* pPass, const ezRenderDataBatch& batch) override;
65 
66 protected:
67  void SetupRenderer();
68 
69  static const ezUInt32 VertexBufferSize = 10000;
70  static const ezUInt32 IndexBufferSize = VertexBufferSize * 2;
71 
72  ezShaderResourceHandle m_hShader;
73  ezGALBufferHandle m_hVertexBuffer;
74  ezGALBufferHandle m_hIndexBuffer;
75  ezVertexDeclarationInfo m_VertexDeclarationInfo;
76 };
77 
Definition: RendererFoundationDLL.h:327
Encapsulates a view on the given world through the given camera and rendered with the specified Rende...
Definition: View.h:18
Definition: DearImguiRenderer.h:33
Definition: Extractor.h:6
Definition: DearImguiRenderer.h:24
A 8bit per channel unsigned normalized (values interpreted as 0-1) color storage format that represen...
Definition: Color8UNorm.h:40
A 3-component vector class.
Definition: Declarations.h:74
Definition: HybridArray.h:79
#define EZ_DECLARE_POD_TYPE()
Embed this into a class to mark it as a POD type. POD types will get special treatment from allocator...
Definition: TypeTraits.h:128
Base class for all render data. Render data must contain all information that is needed to render the...
Definition: RenderData.h:11
Definition: ExtractedRenderData.h:9
A 2-component vector class.
Definition: Declarations.h:66
Definition: DynamicArray.h:70
Definition: MeshBufferResource.h:21
Definition: Declarations.h:41
Definition: DearImguiRenderer.h:54
Definition: DearImguiRenderer.h:44
Definition: RenderDataBatch.h:5
Definition: RenderPipelinePass.h:27
This is the base class for types that handle rendering of different object types. ...
Definition: Declarations.h:78