Texture implementation basics

This commit is contained in:
2024-07-04 17:00:46 +02:00
parent d79f74c21d
commit 3e73672538
9 changed files with 104 additions and 37 deletions

View 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;
}
}