]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/texture2d.cpp
Unmanage texture if loading data directly
[libs/gl.git] / source / core / texture2d.cpp
index 0e76128c7bc5666da5828f11fe98f5398ecaf380..6e7d97202f341cc12e2a76d9e94b92f840c3ff94 100644 (file)
@@ -106,7 +106,7 @@ void Texture2D::image(unsigned level, const void *data)
        }
 
        PixelComponents comp = get_components(storage_fmt);
-       DataType type = get_component_type(storage_fmt);
+       GLenum type = get_gl_type(get_component_type(storage_fmt));
        glTexImage2D(target, level, storage_fmt, w, h, 0, comp, type, data);
 
        allocated |= 1<<level;
@@ -133,7 +133,7 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht
        allocate(level);
 
        PixelComponents comp = get_components(storage_fmt);
-       DataType type = get_component_type(storage_fmt);
+       GLenum type = get_gl_type(get_component_type(storage_fmt));
        if(ARB_direct_state_access)
                glTextureSubImage2D(id, level, x, y, wd, ht, comp, type, data);
        else
@@ -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());
 }
 
@@ -290,12 +296,7 @@ bool Texture2D::AsyncLoader::process()
                }
 
                if(!texture.id)
-               {
-                       if(ARB_direct_state_access)
-                               glCreateTextures(texture.target, 1, &texture.id);
-                       else
-                               glGenTextures(1, &texture.id);
-               }
+                       texture.generate_id();
                texture.image(image, 0, true);
        }