31 lines
1.0 KiB
C++
31 lines
1.0 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/.
|
|
*/
|
|
|
|
#include "Texture.hpp"
|
|
|
|
namespace OpenVulkano::Scene
|
|
{
|
|
Texture Texture::PLACEHOLDER = Texture(&SamplerConfig::NEAREST, 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;
|
|
m_samplerConfig = &SamplerConfig::NEAREST;
|
|
}
|
|
}
|