Texture implementation basics
This commit is contained in:
@@ -127,7 +127,7 @@ namespace OpenVulkano::Scene
|
||||
{
|
||||
CheckShaderInitState();
|
||||
if (setId < 0) setId = static_cast<int>(descriptorSets.size() + 2);
|
||||
if (setId < 2) throw std::runtime_error("Cant bind set id 0 or 1!");
|
||||
if (setId < 2) throw std::runtime_error("Cant bind set id 0 or 1! They are used for node and camera!");
|
||||
setId -= 2;
|
||||
while (setId >= static_cast<int>(descriptorSets.size()))
|
||||
{
|
||||
|
||||
30
openVulkanoCpp/Scene/Textrue.cpp
Normal file
30
openVulkanoCpp/Scene/Textrue.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#include "Texture.hpp"
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
Texture Texture::PLACEHOLDER = Texture(true);
|
||||
|
||||
void Texture::MakePlaceholder(uint32_t width, uint32_t height, Math::Vector4uc color1, Math::Vector4uc color2)
|
||||
{
|
||||
if (textureBuffer) throw std::runtime_error("Texture data already initialized");
|
||||
Math::Vector4uc* imageMemory = new Math::Vector4uc[width * height]();
|
||||
for (uint32_t row = 0; row < height; row++)
|
||||
{
|
||||
for (uint32_t col = 0; col < width; col++)
|
||||
{
|
||||
imageMemory[row * width + col] = (((row & 0x10) == 0) ^ ((col & 0x10) == 0 )) ? color2 : color1;
|
||||
}
|
||||
}
|
||||
textureBuffer = imageMemory;
|
||||
resolution = {width, height, 1};
|
||||
size = sizeof(Math::Vector4uc) * width * height;
|
||||
format = DataFormat::B8G8R8A8_UNORM;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,30 @@
|
||||
#include "UpdateFrequency.hpp"
|
||||
#include "Base/ICloseable.hpp"
|
||||
#include "Math/Math.hpp"
|
||||
#include "DataFormat.hpp"
|
||||
#include "Scene/Shader/DescriptorInputDescription.hpp"
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
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 };
|
||||
|
||||
Texture(bool placeholder = false) { if (placeholder) MakePlaceholder(); }
|
||||
|
||||
ICloseable* renderTexture = nullptr;
|
||||
void* textureBuffer;
|
||||
Math::Vector3ui resolution;
|
||||
size_t size;
|
||||
void* textureBuffer = nullptr;
|
||||
Math::Vector3ui resolution = {0,0,0};
|
||||
size_t size = 0;
|
||||
DataFormat format = DataFormat::B8G8R8A8_UNORM;
|
||||
bool updated = true;
|
||||
UpdateFrequency updateFrequency = UpdateFrequency::Never;
|
||||
ICloseable* vulkanTexture = nullptr;
|
||||
|
||||
|
||||
|
||||
void MakePlaceholder(uint32_t width = 128, uint32_t height = 128,
|
||||
Math::Vector4uc color1 = {255, 135, 255, 255}, Math::Vector4uc color2 = {255, 225, 255, 255});
|
||||
};
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
enum class UpdateFrequency : uint8_t
|
||||
|
||||
Reference in New Issue
Block a user