From 412996297a287c9e97a7207458877c0ab07cc8b6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 18 Apr 2021 01:05:20 +0300 Subject: [PATCH] Unmanage texture if loading data directly Otherwise the resource manager won't have a load location for the texture and will throw an exception. Also generate ID if it hasn't been done yet. --- source/core/texture.cpp | 7 +++++++ source/core/texture2d.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/source/core/texture.cpp b/source/core/texture.cpp index 3eb48b8b..354c1b12 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -361,6 +361,13 @@ void Texture::Loader::generate_mipmap(bool gm) void Texture::Loader::image_data(const string &data) { + if(obj.manager) + { + obj.set_manager(0); + if(!obj.id) + obj.generate_id(); + } + Graphics::Image img; IO::Memory mem(data.data(), data.size()); img.load_io(mem); diff --git a/source/core/texture2d.cpp b/source/core/texture2d.cpp index 0f06790c..6e7d9720 100644 --- a/source/core/texture2d.cpp +++ b/source/core/texture2d.cpp @@ -230,6 +230,12 @@ void Texture2D::Loader::init() void Texture2D::Loader::raw_data(const string &data) { + if(obj.manager) + { + obj.set_manager(0); + if(!obj.id) + obj.generate_id(); + } obj.image(0, data.data()); } -- 2.43.0