X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fresources.cpp;fp=source%2Fresources.cpp;h=8cdd0ad8f0b12066adf3b3dfeed9c2029ec304ee;hb=38cb882b67cf1e31473c9a0c1c9ed12418e059e5;hp=36be79e7914272d76a30c4c5af904c8fa5dc6cee;hpb=a6733b168083926ccc11eb3896642348b13817a2;p=libs%2Fgltk.git diff --git a/source/resources.cpp b/source/resources.cpp index 36be79e..8cdd0ad 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -49,17 +49,19 @@ GL::Texture2D *Resources::create_texture(const string &name) { string ext = FS::extpart(name); if(ext==".png" || ext==".jpg") - { - IO::Seekable *io = open_from_sources(name); - Graphics::Image image; - image.load_io(*io); - GL::Texture2D *tex = new GL::Texture2D; - tex->set_min_filter(GL::LINEAR); - tex->image(image); - return tex; - } - else - return 0; + if(IO::Seekable *io = open_from_sources(name)) + { + Graphics::Image image; + image.load_io(*io); + delete io; + + GL::Texture2D *tex = new GL::Texture2D; + tex->set_min_filter(GL::LINEAR); + tex->image(image); + return tex; + } + + return 0; }