Files
OpenVulkano/openVulkanoCpp/Vulkan/Scene/SimpleDrawableVulkanEncoder.cpp
2023-08-05 21:01:11 +02:00

34 lines
1.3 KiB
C++

/*
* 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 = static_cast<SimpleDrawable*>(instance)->GetMesh();
VulkanGeometry* renderGeo = static_cast<VulkanGeometry*>(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);
static_cast<VulkanNode*>(node->renderNode)->Record(drawContext->commandBuffer, drawContext->currentImageId);
renderGeo->RecordDraw(drawContext->commandBuffer);
}
}
}
namespace
{
void* simpleDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction<SimpleDrawable>(&openVulkanoCpp::Vulkan::EncodeSimpleDrawable);
}