]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2d.cpp
Rearrange texture bind calls to keep them closer to where they're needed
[libs/gl.git] / source / texture2d.cpp
index 4d6e32f5550cd6f48ee68c71d957278b7ffe355e..23cb9477e122c69ddabdbf614dfafca05ed71801 100644 (file)
@@ -89,10 +89,10 @@ void Texture2D::image(unsigned level, PixelFormat fmt, DataType type, const void
        unsigned h = height;
        get_level_size(level, w, h);
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(level, 0, 0, w, h, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage2D(target, level, ifmt, w, h, 0, fmt, type, data);
 
        allocated |= 1<<level;
@@ -108,9 +108,9 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht
        if(width==0 || height==0)
                throw invalid_operation("Texture2D::sub_image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage2D(target, level, x, y, wd, ht, fmt, type, data);
 
        if(gen_mipmap && level==0)