add: ImGui support

This commit is contained in:
Samuliak 2024-08-24 17:03:49 +02:00
parent d4a1074425
commit 7499c3fbe7
7 changed files with 805 additions and 43 deletions

View file

@ -16,6 +16,8 @@ MetalLayerHandle::~MetalLayerHandle()
{
if (m_layer)
m_layer->release();
if (m_renderPassDescriptor)
m_renderPassDescriptor->release();
}
void MetalLayerHandle::Resize(const Vector2i& size)
@ -35,9 +37,27 @@ bool MetalLayerHandle::AcquireDrawable()
return false;
}
if (m_renderPassDescriptor)
{
m_renderPassDescriptor->release();
m_renderPassDescriptor = nullptr;
}
return true;
}
void MetalLayerHandle::CreateRenderPassDescriptor(bool clear)
{
if (m_renderPassDescriptor)
m_renderPassDescriptor->release();
m_renderPassDescriptor = MTL::RenderPassDescriptor::alloc()->init();
auto colorAttachment = m_renderPassDescriptor->colorAttachments()->object(0);
colorAttachment->setTexture(m_drawable->texture());
colorAttachment->setLoadAction(clear ? MTL::LoadActionClear : MTL::LoadActionLoad);
colorAttachment->setStoreAction(MTL::StoreActionStore);
}
void MetalLayerHandle::PresentDrawable(MTL::CommandBuffer* commandBuffer)
{
commandBuffer->presentDrawable(m_drawable);