From: Mikko Rasa Date: Sat, 17 Apr 2021 22:05:20 +0000 (+0300) Subject: Unmanage texture if loading data directly X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=412996297a287c9e97a7207458877c0ab07cc8b6;p=libs%2Fgl.git 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. --- 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()); }