/*
 * 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 "Scene/Texture.hpp"
#include "Vulkan/Scene/VulkanTexture.hpp"
#include <vulkan/vulkan_metal.h>


namespace OpenVulkano::Vulkan
{
	class MetalBackedTexture : public Scene::Texture
	{
		VulkanTexture m_vulkanTexture;
		MTLTexture_id m_metalTexture = nullptr;

	public:
		MetalBackedTexture() = default;

		~MetalBackedTexture() { if (m_vulkanTexture) Close(); }

		void Init(ResourceManager* resManager, MTLTexture_id mtlTexture, bool ownsTexture);

		void Close();

		operator bool() const { return m_vulkanTexture; }
	};
}
