Add handling for camera intrinsics
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "VulkanGeometry.hpp"
|
||||
#include "Vulkan/VulkanDrawContext.hpp"
|
||||
#include "Vulkan/Scene/VulkanTexture.hpp"
|
||||
#include "Vulkan/Scene/VulkanUniformBuffer.hpp"
|
||||
|
||||
using namespace OpenVulkano::Scene;
|
||||
|
||||
@@ -23,7 +24,13 @@ namespace OpenVulkano::Vulkan
|
||||
{
|
||||
vkTexture = drawContext->renderer->GetResourceManager().PrepareTexture(const_cast<Texture*>(texture));
|
||||
}
|
||||
vkTexture->Record(drawContext, 2);
|
||||
VulkanUniformBuffer* vkBuffer = static_cast<VulkanUniformBuffer*>(bgDrawable->GetBuffer().renderBuffer);
|
||||
if (!vkBuffer)
|
||||
{
|
||||
vkBuffer = drawContext->renderer->GetResourceManager().PrepareUniformBuffer(&bgDrawable->GetBuffer());
|
||||
}
|
||||
vkBuffer->Record(drawContext);
|
||||
vkTexture->Record(drawContext, 3);
|
||||
drawContext->commandBuffer.draw(4, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ namespace OpenVulkano::Vulkan
|
||||
|
||||
struct VulkanNodeDynamic : VulkanNode
|
||||
{
|
||||
uint32_t lastUpdate = -1;
|
||||
//uint32_t lastUpdate = -1;
|
||||
|
||||
void Init(Scene::Node* node, UniformBuffer* uniformBuffer) override
|
||||
{
|
||||
VulkanNode::Init(node, uniformBuffer);
|
||||
lastUpdate = -1;
|
||||
//lastUpdate = -1;
|
||||
}
|
||||
|
||||
void Record(VulkanDrawContext* context) override
|
||||
|
||||
68
openVulkanoCpp/Vulkan/Scene/VulkanUniformBuffer.hpp
Normal file
68
openVulkanoCpp/Vulkan/Scene/VulkanUniformBuffer.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Base/ICloseable.hpp"
|
||||
#include "IRecordable.hpp"
|
||||
#include "Scene/UniformBuffer.hpp"
|
||||
#include "Vulkan/Resources/UniformBuffer.hpp"
|
||||
|
||||
namespace OpenVulkano::Vulkan
|
||||
{
|
||||
class VulkanUniformBuffer : public IRecordable, public ICloseable
|
||||
{
|
||||
public:
|
||||
Scene::UniformBuffer* uBuffer = nullptr;
|
||||
UniformBuffer* buffer = nullptr;
|
||||
|
||||
~VulkanUniformBuffer() override
|
||||
{
|
||||
if (uBuffer) VulkanUniformBuffer::Close();
|
||||
}
|
||||
|
||||
virtual void Init(Scene::UniformBuffer* uBuffer, UniformBuffer* uniformBuffer)
|
||||
{
|
||||
this->uBuffer = uBuffer;
|
||||
this->buffer = uniformBuffer;
|
||||
uBuffer->renderBuffer = this;
|
||||
}
|
||||
|
||||
void Record(VulkanDrawContext* context) override
|
||||
{
|
||||
buffer->Record(context);
|
||||
}
|
||||
|
||||
void Close() override
|
||||
{
|
||||
if (uBuffer) uBuffer->renderBuffer = nullptr;
|
||||
delete buffer;
|
||||
uBuffer = nullptr;
|
||||
buffer = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
struct VulkanUniformBufferDynamic : VulkanUniformBuffer
|
||||
{
|
||||
uint32_t lastUpdate = 0;
|
||||
|
||||
void Init(Scene::UniformBuffer* buffer, UniformBuffer* uniformBuffer) override
|
||||
{
|
||||
VulkanUniformBuffer::Init(buffer, uniformBuffer);
|
||||
lastUpdate = -1;
|
||||
}
|
||||
|
||||
void Record(VulkanDrawContext* context) override
|
||||
{
|
||||
if(uBuffer->updated) //TODO fix
|
||||
{
|
||||
//uBuffer->updated = false;
|
||||
buffer->Update(uBuffer->data, uBuffer->size, context->currentImageId);
|
||||
}
|
||||
buffer->Record(context);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user