/* * 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 "UpdateFrequency.hpp" #include "SamplerConfig.hpp" #include "Base/Render/RenderResource.hpp" #include "Math/Math.hpp" #include "DataFormat.hpp" #include "Scene/Shader/DescriptorInputDescription.hpp" namespace OpenVulkano::Scene { class Texture : public RenderResourceHolder { public: static Texture PLACEHOLDER; static constexpr inline DescriptorSetLayoutBinding DESCRIPTOR_SET_LAYOUT_BINDING = { 0, DescriptorSetLayoutBinding::Type::TYPE_COMBINED_IMAGE_SAMPLER, 1, ShaderProgramType::ALL_GRAPHICS }; void* textureBuffer = nullptr; size_t size = 0; Math::Vector3ui resolution = {0,0,0}; DataFormat format = DataFormat::B8G8R8A8_UNORM; UpdateFrequency updateFrequency = UpdateFrequency::Never; const SamplerConfig* m_samplerConfig; bool updated = true; Texture(const SamplerConfig* samplerConfig = &SamplerConfig::DEFAULT, bool placeholder = false) : m_samplerConfig(samplerConfig) { if (placeholder) MakePlaceholder(); } ~Texture() = default; void MakePlaceholder(uint32_t width = 32, uint32_t height = 32, Math::Vector4uc color1 = {248, 123, 255, 255}, Math::Vector4uc color2 = {250, 19, 255, 255}); }; class TextureBinding { public: Texture* texture; int setId; operator bool() const { return setId >= 0 && texture; } }; }