From 51fd0951af4c8f0afe4a3520ba9379c61bd9316b Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 31 Dec 2023 02:43:19 +0100 Subject: [PATCH] Fixed Image initialization. --- game_scene.cpp | 1 + sfw/render_core/image.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/game_scene.cpp b/game_scene.cpp index d3e4c67..c0400de 100644 --- a/game_scene.cpp +++ b/game_scene.cpp @@ -138,6 +138,7 @@ GameScene::GameScene() { image.instance(); image->load_from_file("icon.png"); + //image->bumpmap_to_normalmap(); texture = new Texture(); //texture->load_image("icon.png"); diff --git a/sfw/render_core/image.cpp b/sfw/render_core/image.cpp index d8b0d6c..d5c74cc 100644 --- a/sfw/render_core/image.cpp +++ b/sfw/render_core/image.cpp @@ -1461,9 +1461,9 @@ void Image::load_from_file(const String &file_name, Format p_format) { int size = x * y * get_format_pixel_size(FORMAT_RGBA8); + data.resize(size); { write_lock = true; - data.resize(size); memcpy(data.ptrw(), pixels, size); write_lock = false; } @@ -1812,6 +1812,7 @@ Image::Image(int p_width, int p_height, bool p_use_mipmaps, Format p_format) { height = 0; mipmaps = p_use_mipmaps; format = FORMAT_L8; + write_lock = false; create(p_width, p_height, p_use_mipmaps, p_format); } @@ -1821,6 +1822,7 @@ Image::Image(int p_width, int p_height, bool p_mipmaps, Format p_format, const V height = 0; mipmaps = p_mipmaps; format = FORMAT_L8; + write_lock = false; create(p_width, p_height, p_mipmaps, p_format, p_data); }