diff --git a/openVulkanoCpp/Scene/Texture.hpp b/openVulkanoCpp/Scene/Texture.hpp index 3565105..c95cb37 100644 --- a/openVulkanoCpp/Scene/Texture.hpp +++ b/openVulkanoCpp/Scene/Texture.hpp @@ -28,12 +28,19 @@ namespace OpenVulkano::Scene UpdateFrequency updateFrequency = UpdateFrequency::Never; const SamplerConfig* m_samplerConfig; bool updated = true; + bool ownsData = false; Texture(const SamplerConfig* samplerConfig = &SamplerConfig::DEFAULT, bool placeholder = false) : m_samplerConfig(samplerConfig) { if (placeholder) MakePlaceholder(); } - ~Texture() = default; + Texture(Math::Vector2ui resolution, DataFormat format) : resolution(resolution, 1), format(format), ownsData(true) + { + size = format.CalculatedSize(resolution.x, resolution.y); + textureBuffer = malloc(size); + } + + ~Texture() { if (ownsData) free(textureBuffer); } void MakePlaceholder(uint32_t width = 32, uint32_t height = 32, Math::Vector4uc color1 = {248, 123, 255, 255}, Math::Vector4uc color2 = {250, 19, 255, 255});