Change TextDrawable base class
This commit is contained in:
58
openVulkanoCpp/Vulkan/Scene/TextDrawableVulkanEncoder.cpp
Normal file
58
openVulkanoCpp/Vulkan/Scene/TextDrawableVulkanEncoder.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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/TextDrawable.hpp"
|
||||
#include "VulkanGeometry.hpp"
|
||||
#include "VulkanNode.hpp"
|
||||
#include "Vulkan/VulkanDrawContext.hpp"
|
||||
#include "Vulkan/Scene/VulkanUniformBuffer.hpp"
|
||||
#include "VulkanTexture.hpp"
|
||||
|
||||
using namespace OpenVulkano::Scene;
|
||||
|
||||
namespace OpenVulkano::Vulkan
|
||||
{
|
||||
void EncodeTextDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext)
|
||||
{
|
||||
TextDrawable* drawable = static_cast<TextDrawable*>(instance);
|
||||
Geometry* mesh = drawable->GetGeometry();
|
||||
VulkanGeometry* renderGeo = mesh->GetRenderResource();
|
||||
if (!renderGeo) renderGeo = drawContext->renderer->GetResourceManager().PrepareGeometry(mesh);
|
||||
renderGeo->RecordBind(drawContext->commandBuffer);
|
||||
|
||||
if (drawable->GetUniformBuffer())
|
||||
{
|
||||
VulkanUniformBuffer* vkBuffer = drawable->GetUniformBuffer()->GetRenderResource();
|
||||
if (!vkBuffer)
|
||||
{
|
||||
vkBuffer = drawContext->renderer->GetResourceManager().PrepareUniformBuffer(drawable->GetUniformBuffer());
|
||||
}
|
||||
vkBuffer->Record(drawContext);
|
||||
}
|
||||
|
||||
if (Texture* texture = drawable->GetTexture())
|
||||
{
|
||||
VulkanTexture* renderTexture = texture->GetRenderResource();
|
||||
if (!renderTexture)
|
||||
{
|
||||
renderTexture = drawContext->renderer->GetResourceManager().PrepareTexture(drawable->GetTexture());
|
||||
}
|
||||
renderTexture->Record(drawContext);
|
||||
}
|
||||
|
||||
for(Node* node : instance->GetNodes())
|
||||
{
|
||||
if (!node->IsEnabled()) [[unlikely]] continue;
|
||||
drawContext->EncodeNode(node);
|
||||
renderGeo->RecordDraw(drawContext->commandBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
[[maybe_unused]] void* textDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction<TextDrawable>(&OpenVulkano::Vulkan::EncodeTextDrawable);
|
||||
}
|
||||
Reference in New Issue
Block a user