fixing SDL issue on windows

This commit is contained in:
Kbz-8
2023-12-31 01:08:41 +01:00
parent f3efb72a21
commit 4087fca980
10 changed files with 72 additions and 65 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/31 18:03:35 by maldavid #+# #+# */
/* Updated: 2023/12/23 18:49:53 by kbz_8 ### ########.fr */
/* Updated: 2023/12/31 00:49:16 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -54,18 +54,27 @@ namespace mlx
_ibo.create(sizeof(uint16_t) * indexData.size(), indexData.data(), nullptr);
#endif
Buffer staging_buffer;
std::size_t size = width * height * formatSize(format);
if(pixels != nullptr)
{
Buffer staging_buffer;
std::size_t size = width * height * formatSize(format);
#ifdef DEBUG
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, name, pixels);
#else
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, nullptr, pixels);
#endif
Image::copyFromBuffer(staging_buffer);
staging_buffer.destroy();
}
else
{
std::vector<uint32_t> default_pixels(width * height, 0x00000000);
#ifdef DEBUG
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, name, default_pixels.data());
#else
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, nullptr, default_pixels.data());
#endif
}
Image::copyFromBuffer(staging_buffer);
staging_buffer.destroy();
}
void Texture::setPixel(int x, int y, uint32_t color) noexcept

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/07 16:40:09 by maldavid #+# #+# */
/* Updated: 2023/12/22 23:39:38 by kbz_8 ### ########.fr */
/* Updated: 2023/12/31 00:52:01 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -27,14 +27,16 @@ namespace mlx
Image::createSampler();
transitionLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
if(pixels != nullptr)
if(pixels == nullptr)
{
Buffer staging_buffer;
std::size_t size = width * height * formatSize(format);
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, name, pixels);
Image::copyFromBuffer(staging_buffer);
staging_buffer.destroy();
core::error::report(e_kind::warning, "Renderer : creating an empty texture atlas. They cannot be updated after creation, this might be a mistake or a bug, please report");
return;
}
Buffer staging_buffer;
std::size_t size = width * height * formatSize(format);
staging_buffer.create(Buffer::kind::dynamic, size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, name, pixels);
Image::copyFromBuffer(staging_buffer);
staging_buffer.destroy();
}
void TextureAtlas::render(Renderer& renderer, int x, int y, uint32_t ibo_size) const