PeriDyno 1.0.0
Loading...
Searching...
No Matches
TriangleSetRenderer.h
Go to the documentation of this file.
1#pragma once
2#include <array>
3
4#include "VkSystem.h"
5#include "VulkanTools.h"
6#include "VkContext.h"
7#include "VkSystem.h"
8#include "VkDeviceArray.h"
9#include "VkUniform.h"
10#include "VkVisualModule.h"
11
12#include "Topology/TriangleSet.h"
13
14using namespace dyno;
15
16namespace dyno {
17
18 struct Vertex
19 {
20 glm::vec4 pos;
21 glm::vec4 uv;
22 glm::vec4 normal;
23 };
24
25 //TODO: implement an easy to use graphics pipeline that can be adapted into the framework
27 {
28 public:
30
32
34
35 void prepare(VkRenderPass renderPass) override
36 {
37 this->updateGraphicsUBO();
38
39 this->setupDescriptorPool();
41
42 this->preparePipelines(renderPass);
43 }
44
46
48
49 void preparePipelines(VkRenderPass renderPass);
50
51 void addGraphicsToComputeBarriers(VkCommandBuffer commandBuffer);
52
53 void addComputeToGraphicsBarriers(VkCommandBuffer commandBuffer);
54
55 void buildCommandBuffers(VkCommandBuffer drawCmdBuffer) override;
56
58 {
59 mUniform.setValue(ubo);
60 }
61
62 void viewChanged(const glm::mat4& perspective, const glm::mat4& view) override
63 {
64 ubo.projection = perspective;
65 ubo.view = view;
66 mUniform.setValue(ubo);
67 }
68
69 private:
70 std::shared_ptr<VkProgram> program;
71
73
74 protected:
75 bool initializeImpl() override;
76 void updateGraphicsContext() override;
77
78 std::string getShadersPath() const;
79
80 VkPipelineShaderStageCreateInfo loadShader(std::string fileName, VkShaderStageFlagBits stage);
81
82 private:
83 std::string shaderDir = "glsl";
84
86
87 VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
88
90
91 // Resources for the rendering pipeline
92 VkDescriptorSetLayout descriptorSetLayout;
93 VkDescriptorSet descriptorSet;
94 VkPipelineLayout pipelineLayout;
95 VkPipeline pipeline;
96 std::vector<VkShaderModule> shaderModules;
97
98 public:
99 struct GraphicsUBO {
100 glm::mat4 projection;
101 glm::mat4 view;
102 glm::vec4 lightPos = glm::vec4(-2.0f, 4.0f, -2.0f, 1.0f);
104
107
109 };
110}
111
struct dyno::TriangleSetRenderer::GraphicsUBO ubo
void addComputeToGraphicsBarriers(VkCommandBuffer commandBuffer)
VkConstant< uint32_t > particleNumber
void viewChanged(const glm::mat4 &perspective, const glm::mat4 &view) override
VkPipelineShaderStageCreateInfo loadShader(std::string fileName, VkShaderStageFlagBits stage)
VkUniform< GraphicsUBO > mUniform
void buildCommandBuffers(VkCommandBuffer drawCmdBuffer) override
void prepare(VkRenderPass renderPass) override
void preparePipelines(VkRenderPass renderPass)
DEF_INSTANCE_IN(TriangleSet, Topology, "")
VkDeviceArray< Vertex > mVertex
VkDescriptorSetLayout descriptorSetLayout
std::vector< VkShaderModule > shaderModules
std::shared_ptr< VkProgram > program
void addGraphicsToComputeBarriers(VkCommandBuffer commandBuffer)
VkDeviceArray< uint32_t > mIndex
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25