Files
OpenVulkano/openVulkanoCpp/Scene/Texture.hpp
2024-07-23 22:01:07 +02:00

61 lines
1.5 KiB
C++

/*
* 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 "Base/ICloseable.hpp"
#include "Math/Math.hpp"
#include "DataFormat.hpp"
#include "Scene/Shader/DescriptorInputDescription.hpp"
namespace OpenVulkano::Scene
{
class Texture;
struct RenderTexture
{
Texture* m_texture = nullptr;
};
class Texture
{
public:
static Texture PLACEHOLDER;
static constexpr inline DescriptorSetLayoutBinding DESCRIPTOR_SET_LAYOUT_BINDING = { 0, DescriptorSetLayoutBinding::Type::TYPE_COMBINED_IMAGE_SAMPLER, 1, ShaderProgramType::ALL_GRAPHICS };
RenderTexture* renderTexture = nullptr;
void* textureBuffer = nullptr;
size_t size = 0;
Math::Vector3ui resolution = {0,0,0};
DataFormat format = DataFormat::B8G8R8A8_UNORM;
bool updated = true;
UpdateFrequency updateFrequency = UpdateFrequency::Never;
Texture(bool placeholder = false) { if (placeholder) MakePlaceholder(); }
~Texture()
{
if (renderTexture)
{
renderTexture->m_texture = nullptr;
}
}
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; }
};
}