]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture3d.cpp
Rearrange texture bind calls to keep them closer to where they're needed
[libs/gl.git] / source / texture3d.cpp
index 7ea17b137e545d0fcc757173799f3598998788cb..36afa9bcdfe9b3fc2dc1e72c5ef8d19bce06f8aa 100644 (file)
@@ -78,10 +78,10 @@ void Texture3D::image(unsigned level, PixelFormat fmt, DataType type, const void
        unsigned d = depth;
        get_level_size(level, w, h, d);
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(level, 0, 0, 0, w, h, d, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage3D(target, level, ifmt, width, height, depth, 0, fmt, type, data);
 
        allocated |= 1<<level;
@@ -97,9 +97,9 @@ void Texture3D::sub_image(unsigned level, int x, int y, int z, unsigned wd, unsi
        if(width==0 || height==0 || depth==0)
                throw invalid_operation("Texture3D::image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage3D(target, level, x, y, z, wd, ht, dp, fmt, type, data);
 
        if(gen_mipmap && level==0)