]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Rearrange texture bind calls to keep them closer to where they're needed
[libs/gl.git] / source / texturecube.cpp
index a9961af90a3900660f2e2c71a5a46be8820f6441..e767423fe539f9ee92fd10dd5af8f1beaa6eebb4 100644 (file)
@@ -77,10 +77,10 @@ void TextureCube::image(TextureCubeFace face, unsigned level, PixelFormat fmt, D
        if(s==0)
                throw out_of_range("TextureCube::image");
 
-       BindRestore _bind(this);
        if(ARB_texture_storage)
                return sub_image(face, level, 0, 0, s, s, fmt, type, data);
 
+       BindRestore _bind(this);
        glTexImage2D(face, level, ifmt, s, s, 0, fmt, type, data);
 
        // XXX Allocation should be tracked per-face, but we'll run out of bits
@@ -98,9 +98,9 @@ void TextureCube::sub_image(TextureCubeFace face, unsigned level, int x, int y,
        if(size==0)
                throw invalid_operation("TextureCube::sub_image");
 
+       BindRestore _bind(this);
        allocate(level);
 
-       BindRestore _bind(this);
        glTexSubImage2D(face, level, x, y, wd, ht, fmt, type, data);
 
        if(gen_mipmap && level==0)