Add ArBackgroundDrawable

This commit is contained in:
Georg Hagen
2024-07-07 00:37:49 +02:00
parent 52941b99cc
commit 87ce56b894
10 changed files with 197 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
/*
* 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/Prefabs/ArBackgroundDrawable.hpp"
#include "VulkanGeometry.hpp"
#include "Vulkan/VulkanDrawContext.hpp"
#include "Vulkan/Scene/VulkanTexture.hpp"
using namespace OpenVulkano::Scene;
namespace OpenVulkano::Vulkan
{
void EncodeArBackgroundDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext)
{
ArBackgroundDrawable* bgDrawable = static_cast<ArBackgroundDrawable*>(instance);
bgDrawable->Tick();
const Texture* texture = bgDrawable->GetTexture();
VulkanTexture* vkTexture = static_cast<VulkanTexture*>(texture->renderTexture);
if (!vkTexture)
{
vkTexture = drawContext->renderer->GetResourceManager().PrepareTexture(const_cast<Texture*>(texture));
}
vkTexture->Record(drawContext, 2);
drawContext->commandBuffer.draw(4, 1, 0, 0);
}
}
namespace
{
void* arBgDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction<ArBackgroundDrawable>(&OpenVulkano::Vulkan::EncodeArBackgroundDrawable);
}