X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture.cpp;h=967a7fe31562d8509619b3bef3d060c3bd75d714;hb=fcde8390ad577fe434dcd4b29e0f410d29f867c9;hp=3eb48b8b2eb426dafebd1791ab11d4fba09b4c63;hpb=2e7f0e8b226fdeea3306e2e0eef22a8f200ae16b;p=libs%2Fgl.git diff --git a/source/core/texture.cpp b/source/core/texture.cpp index 3eb48b8b..967a7fe3 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include "bindable.h" #include "error.h" @@ -55,6 +56,11 @@ void Texture::generate_id() glCreateTextures(target, 1, &id); else glGenTextures(1, &id); + +#ifdef DEBUG + if(!debug_name.empty() && KHR_debug) + glObjectLabel(GL_TEXTURE, id, debug_name.size(), debug_name.c_str()); +#endif } void Texture::set_format(PixelFormat fmt) @@ -277,6 +283,17 @@ void Texture::unbind_from(unsigned i) } } +void Texture::set_debug_name(const string &name) +{ +#ifdef DEBUG + debug_name = name; + if(id && KHR_debug) + glObjectLabel(GL_TEXTURE, id, name.size(), name.c_str()); +#else + (void)name; +#endif +} + Texture::Loader::Loader(Texture &t): DataFile::CollectionObjectLoader(t, 0) @@ -361,6 +378,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);