Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
Mesh3dRenderer.hpp
1#pragma once
2
3#include <string>
4#include <vector>
5#include <map>
6#include <glm/mat4x4.hpp>
7
8#include "EngineCore/AssetRenderer/BaseAssetRenderer.hpp"
9#include "Components/MeshRendererComponent.hpp"
10#include "Assets/Mesh3dAsset.hpp"
11
12namespace Grindstone {
13 namespace GraphicsAPI {
14 class CommandBuffer;
15 class DescriptorSet;
16 }
17
18 struct RenderTask {
19 GraphicsAPI::DescriptorSet* materialDescriptorSet;
20 GraphicsAPI::DescriptorSet* perDrawDescriptorSet;
21 class GraphicsAPI::GraphicsPipeline* pipeline;
22 class GraphicsAPI::VertexArrayObject* vertexArrayObject;
23 uint32_t indexCount;
24 uint32_t baseVertex;
25 uint32_t baseIndex;
26 glm::mat4 transformMatrix;
27 uint32_t sortData;
28 };
29
30 using RenderTaskList = std::vector<RenderTask>;
31 using SortedRender = std::vector<size_t>;
32
34 size_t renderTaskIndex;
35 uint32_t sortData;
36 };
37
38 struct Mesh3dUbo {
39 glm::mat4 modelMatrix;
40 };
41
43 DrawSortMode sortMode;
44 RenderTaskList renderTasks;
45 std::vector<RenderSortData> renderSortData;
46
47 RenderQueueContainer() = default;
48 RenderQueueContainer(DrawSortMode drawSortMode) {
49 sortMode = drawSortMode;
50 }
51 };
52
53 class EngineCore;
54
56 public:
57 Mesh3dRenderer(EngineCore* engineCore);
58
59 virtual void AddQueue(const char* queueName, DrawSortMode sortMode);
60 virtual void RenderShadowMap(GraphicsAPI::CommandBuffer* commandBuffer, GraphicsAPI::DescriptorSet* lightingDescriptorSet, entt::registry& registry, glm::vec3 lightSourcePosition) override;
61 virtual void RenderQueue(GraphicsAPI::CommandBuffer* commandBuffer, const char* queueName) override;
62 virtual void CacheRenderTasksAndFrustumCull(glm::vec3 eyePosition, entt::registry& registry) override;
63 virtual void SortQueues() override;
64 GraphicsAPI::DescriptorSetLayout* GetPerDrawDescriptorSetLayout() const;
65 private:
66 virtual std::string GetName() const override;
67 virtual void SetEngineDescriptorSet(GraphicsAPI::DescriptorSet* descriptorSet) override;
68
69 EngineCore* engineCore = nullptr;
70 std::string rendererName = "Mesh3d";
71 GraphicsAPI::DescriptorSet* engineDescriptorSet = nullptr;
72 class GraphicsAPI::DescriptorSetLayout* perDrawDescriptorSetLayout = nullptr;
73
74 public:
75 std::map<std::string, RenderQueueIndex> renderQueueMap;
76 std::vector<RenderQueueContainer> renderQueues;
77 };
78}
Definition BaseAssetRenderer.hpp:25
Definition EngineCore.hpp:57
Definition CommandBuffer.hpp:21
Definition DescriptorSetLayout.hpp:11
Definition DescriptorSet.hpp:11
Definition GraphicsPipeline.hpp:18
Definition VertexArrayObject.hpp:10
Definition Mesh3dRenderer.hpp:55
Definition Mesh3dRenderer.hpp:38
Definition Mesh3dRenderer.hpp:42
Definition Mesh3dRenderer.hpp:33
Definition Mesh3dRenderer.hpp:18