Some more TexturePreparations #11

This commit is contained in:
Georg Hagen
2024-06-11 10:25:06 +02:00
parent 7d7ca4e250
commit 6962ce0bcf
5 changed files with 26 additions and 10 deletions

View File

@@ -5,9 +5,11 @@
*/
#include "Scene/SimpleDrawable.hpp"
#include "Scene/Material.hpp"
#include "VulkanGeometry.hpp"
#include "VulkanNode.hpp"
#include "Vulkan/VulkanDrawContext.hpp"
#include "VulkanTexture.hpp"
using namespace OpenVulkano::Scene;
@@ -15,10 +17,25 @@ namespace OpenVulkano::Vulkan
{
void EncodeSimpleDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext)
{
Geometry* mesh = static_cast<SimpleDrawable*>(instance)->GetMesh();
SimpleDrawable* drawable = static_cast<SimpleDrawable*>(instance);
Geometry* mesh = drawable->GetMesh();
VulkanGeometry* renderGeo = static_cast<VulkanGeometry*>(mesh->renderGeo);
if (!mesh->renderGeo) renderGeo = drawContext->renderer->GetResourceManager().PrepareGeometry(mesh);
if (!renderGeo) renderGeo = drawContext->renderer->GetResourceManager().PrepareGeometry(mesh);
renderGeo->RecordBind(drawContext->commandBuffer);
if (Material* material = drawable->GetMaterial())
{
if (Texture* texture = material->texture)
{
VulkanTexture* renderTexture = static_cast<VulkanTexture*>(texture->renderTexture);
if (!renderTexture)
{
drawContext->renderer->GetResourceManager().PrepareMaterial(drawable->GetMaterial());
renderTexture = static_cast<VulkanTexture*>(texture->renderTexture);
}
renderTexture->Record(drawContext);
}
}
for(Node* node : instance->GetNodes())
{
drawContext->EncodeNode(node);