TileSet
This commit is contained in:
@ -64,10 +64,11 @@ namespace ia::iae
|
||||
}
|
||||
|
||||
SDL_GPUTexture *GPUResourceManager::CreateTexture(IN SDL_GPUTextureUsageFlags usage, IN INT32 width,
|
||||
IN INT32 height, IN PCUINT8 rgbaData,
|
||||
IN INT32 height, IN INT32 stride, IN PCUINT8 rgbaData,
|
||||
IN SDL_GPUTextureFormat format, IN BOOL generateMipmaps)
|
||||
{
|
||||
const auto mipLevels = 1;//generateMipmaps ? ia_max((UINT32)(floor(log2(ia_max(width, height))) + 1), (UINT32)1) : (UINT32)1;
|
||||
const auto mipLevels =
|
||||
1; // generateMipmaps ? ia_max((UINT32)(floor(log2(ia_max(width, height))) + 1), (UINT32)1) : (UINT32)1;
|
||||
|
||||
STATIC Vector<UINT8> TMP_COLOR_BUFFER;
|
||||
|
||||
@ -87,15 +88,33 @@ namespace ia::iae
|
||||
}
|
||||
if (rgbaData)
|
||||
{
|
||||
TMP_COLOR_BUFFER.reset();
|
||||
TMP_COLOR_BUFFER.resize(width * height * 4);
|
||||
for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++)
|
||||
|
||||
if (stride == width)
|
||||
{
|
||||
const auto a = static_cast<FLOAT32>(rgbaData[i * 4 + 3]) / 255.0f;
|
||||
TMP_COLOR_BUFFER[i * 4 + 0] = static_cast<UINT8>(rgbaData[i * 4 + 0] * a);
|
||||
TMP_COLOR_BUFFER[i * 4 + 1] = static_cast<UINT8>(rgbaData[i * 4 + 1] * a);
|
||||
TMP_COLOR_BUFFER[i * 4 + 2] = static_cast<UINT8>(rgbaData[i * 4 + 2] * a);
|
||||
TMP_COLOR_BUFFER[i * 4 + 3] = rgbaData[i * 4 + 3];
|
||||
for (SIZE_T i = 0; i < TMP_COLOR_BUFFER.size() >> 2; i++)
|
||||
{
|
||||
const auto a = static_cast<FLOAT32>(rgbaData[i * 4 + 3]) / 255.0f;
|
||||
TMP_COLOR_BUFFER[i * 4 + 0] = static_cast<UINT8>(rgbaData[i * 4 + 0] * a);
|
||||
TMP_COLOR_BUFFER[i * 4 + 1] = static_cast<UINT8>(rgbaData[i * 4 + 1] * a);
|
||||
TMP_COLOR_BUFFER[i * 4 + 2] = static_cast<UINT8>(rgbaData[i * 4 + 2] * a);
|
||||
TMP_COLOR_BUFFER[i * 4 + 3] = rgbaData[i * 4 + 3];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(INT32 y = 0; y < height; y++)
|
||||
{
|
||||
for(INT32 x = 0; x < width; x++)
|
||||
{
|
||||
const auto p = &rgbaData[(x + y * stride) * 4];
|
||||
const auto a = static_cast<FLOAT32>(p[3]) / 255.0f;
|
||||
TMP_COLOR_BUFFER[(x + y * width) * 4 + 0] = static_cast<UINT8>(p[0] * a);
|
||||
TMP_COLOR_BUFFER[(x + y * width) * 4 + 1] = static_cast<UINT8>(p[1] * a);
|
||||
TMP_COLOR_BUFFER[(x + y * width) * 4 + 2] = static_cast<UINT8>(p[2] * a);
|
||||
TMP_COLOR_BUFFER[(x + y * width) * 4 + 3] = p[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_GPUTransferBufferCreateInfo stagingBufferCreateInfo{.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
|
||||
|
||||
Reference in New Issue
Block a user