/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include "Scene/SimpleDrawable.hpp" #include "VulkanGeometry.hpp" #include "VulkanNode.hpp" #include "Vulkan/VulkanDrawContext.hpp" using namespace openVulkanoCpp::Scene; namespace openVulkanoCpp::Vulkan { void EncodeSimpleDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext) { Geometry* mesh = dynamic_cast(instance)->GetMesh(); VulkanGeometry* renderGeo = dynamic_cast(mesh->renderGeo); if (!mesh->renderGeo) renderGeo = drawContext->renderer->GetResourceManager().PrepareGeometry(mesh); renderGeo->RecordBind(drawContext->commandBuffer); for(Node* node : instance->GetNodes()) { if (!node->renderNode) drawContext->renderer->GetResourceManager().PrepareNode(node); dynamic_cast(node->renderNode)->Record(drawContext->commandBuffer, drawContext->currentImageId); renderGeo->RecordDraw(drawContext->commandBuffer); } } } namespace { void* simpleDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction(&openVulkanoCpp::Vulkan::EncodeSimpleDrawable); }