summaryrefslogtreecommitdiffstats
path: root/src/RendererSection.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2022-12-15 16:41:06 +0100
committerGitHub <noreply@github.com>2022-12-15 16:41:06 +0100
commitd2b2f223cc62a1cc6e9d41d32020ef94d229a581 (patch)
treede0685c59a55557893d8d6d64bad01e9c98d206a /src/RendererSection.cpp
parentMerge pull request #82 from LaG1924/fix/sdl-wayland-build (diff)
parentAdded liquid rendering pass (diff)
downloadAltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.gz
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.bz2
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.lz
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.xz
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.tar.zst
AltCraft-d2b2f223cc62a1cc6e9d41d32020ef94d229a581.zip
Diffstat (limited to 'src/RendererSection.cpp')
-rw-r--r--src/RendererSection.cpp54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/RendererSection.cpp b/src/RendererSection.cpp
index 429a8bd..7ea74df 100644
--- a/src/RendererSection.cpp
+++ b/src/RendererSection.cpp
@@ -9,16 +9,26 @@
#include "RendererSectionData.hpp"
-RendererSection::RendererSection(const RendererSectionData& data, std::shared_ptr<Gal::Pipeline> pipeline, std::shared_ptr<Gal::BufferBinding> bufferBinding) {
+RendererSection::RendererSection(const RendererSectionData& data,
+ std::shared_ptr<Gal::Pipeline> solidPipeline,
+ std::shared_ptr<Gal::BufferBinding> solidBufferBinding,
+ std::shared_ptr<Gal::Pipeline> liquidPipeline,
+ std::shared_ptr<Gal::BufferBinding> liquidBufferBinding) {
OPTICK_EVENT();
auto gal = Gal::GetImplementation();
- buffer = gal->CreateBuffer();
- pipelineInstance = pipeline->CreateInstance({
- {bufferBinding, buffer}
+ solidBuffer = gal->CreateBuffer();
+ solidPipelineInstance = solidPipeline->CreateInstance({
+ {solidBufferBinding, solidBuffer}
});
- pipelineInstance->SetInstancesCount(4);
+ solidPipelineInstance->SetInstancesCount(4);
+
+ liquidBuffer = gal->CreateBuffer();
+ liquidPipelineInstance = liquidPipeline->CreateInstance({
+ {liquidBufferBinding, liquidBuffer}
+ });
+ liquidPipelineInstance->SetInstancesCount(4);
UpdateData(data);
}
@@ -32,18 +42,27 @@ RendererSection::~RendererSection() {
}
-void swap(RendererSection & lhs, RendererSection & rhs) {
- std::swap(lhs.pipelineInstance, rhs.pipelineInstance);
- std::swap(lhs.buffer, rhs.buffer);
- std::swap(lhs.hash, rhs.hash);
- std::swap(lhs.numOfFaces, rhs.numOfFaces);
- std::swap(lhs.sectionPos, rhs.sectionPos);
+void RendererSection::RenderSolid() {
+ OPTICK_EVENT();
+ solidPipelineInstance->Activate();
+ solidPipelineInstance->Render(0, solidFacesCount);
}
-void RendererSection::Render() {
+void RendererSection::RenderLiquid() {
OPTICK_EVENT();
- pipelineInstance->Activate();
- pipelineInstance->Render(0, numOfFaces);
+ liquidPipelineInstance->Activate();
+ liquidPipelineInstance->Render(0, liquidFacesCount);
+}
+
+void swap(RendererSection & lhs, RendererSection & rhs) {
+ std::swap(lhs.solidPipelineInstance, rhs.solidPipelineInstance);
+ std::swap(lhs.solidBuffer, rhs.solidBuffer);
+ std::swap(lhs.liquidPipelineInstance, rhs.liquidPipelineInstance);
+ std::swap(lhs.liquidBuffer, rhs.liquidBuffer);
+ std::swap(lhs.hash, rhs.hash);
+ std::swap(lhs.solidFacesCount, rhs.solidFacesCount);
+ std::swap(lhs.liquidFacesCount, rhs.liquidFacesCount);
+ std::swap(lhs.sectionPos, rhs.sectionPos);
}
Vector RendererSection::GetPosition() {
@@ -57,9 +76,12 @@ size_t RendererSection::GetHash() {
void RendererSection::UpdateData(const RendererSectionData & data) {
OPTICK_EVENT();
- buffer->SetData({ reinterpret_cast<const std::byte*>(data.vertices.data()), reinterpret_cast<const std::byte*>(data.vertices.data() + data.vertices.size())});
+ solidBuffer->SetData({ reinterpret_cast<const std::byte*>(data.solidVertices.data()), reinterpret_cast<const std::byte*>(data.solidVertices.data() + data.solidVertices.size())});
+ solidFacesCount = data.solidVertices.size();
+
+ liquidBuffer->SetData({ reinterpret_cast<const std::byte*>(data.liquidVertices.data()), reinterpret_cast<const std::byte*>(data.liquidVertices.data() + data.liquidVertices.size()) });
+ liquidFacesCount = data.liquidVertices.size();
- numOfFaces = data.vertices.size();
sectionPos = data.sectionPos;
hash = data.hash;
}