Files
OpenVulkano/openVulkanoCpp/Vulkan/Scene/SimpleDrawableVulkanEncoder.cpp

33 lines
1.1 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 OpenVulkano::Scene;
namespace OpenVulkano::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())
{
drawContext->EncodeNode(node);
renderGeo->RecordDraw(drawContext->commandBuffer);
}
}
}
namespace
{
void* simpleDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction<SimpleDrawable>(&OpenVulkano::Vulkan::EncodeSimpleDrawable);
}