]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/texturecube_backend.cpp
Adjust access to main class members from backend classes
[libs/gl.git] / source / backends / opengl / texturecube_backend.cpp
index 1cc3f8377f23eaf3027d8e54caeb58f83dbefd7b..142e343dd9984bb881148ee3dd66739c9cddf3e3 100644 (file)
@@ -28,8 +28,7 @@ OpenGLTextureCube::OpenGLTextureCube():
 
 void OpenGLTextureCube::allocate()
 {
-       unsigned size = static_cast<const TextureCube *>(this)->size;
-       unsigned levels = static_cast<const TextureCube *>(this)->levels;
+       const TextureCube &self = *static_cast<const TextureCube *>(this);
 
        if(!id)
                create();
@@ -38,11 +37,11 @@ void OpenGLTextureCube::allocate()
        if(ARB_texture_storage)
        {
                if(ARB_direct_state_access)
-                       glTextureStorage2D(id, levels, gl_fmt, size, size);
+                       glTextureStorage2D(id, self.levels, gl_fmt, self.size, self.size);
                else
                {
                        bind_scratch();
-                       glTexStorage2D(target, levels, gl_fmt, size, size);
+                       glTexStorage2D(target, self.levels, gl_fmt, self.size, self.size);
                }
        }
        else
@@ -50,13 +49,13 @@ void OpenGLTextureCube::allocate()
                bind_scratch();
                GLenum comp = get_gl_components(get_components(storage_fmt));
                GLenum type = get_gl_type(get_component_type(storage_fmt));
-               for(unsigned i=0; i<levels; ++i)
+               for(unsigned i=0; i<self.levels; ++i)
                {
                        unsigned lv_size = static_cast<const TextureCube *>(this)->get_level_size(i);
                        for(unsigned j=0; j<6; ++j)
                                glTexImage2D(get_gl_cube_face(j), i, gl_fmt, lv_size, lv_size, 0, comp, type, 0);
                }
-               glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1);
+               glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, self.levels-1);
        }
 
        apply_swizzle();
@@ -80,12 +79,11 @@ size_t OpenGLTextureCube::get_data_size() const
        if(!id)
                return 0;
 
-       unsigned size = static_cast<const TextureCube *>(this)->size;
-       unsigned levels = static_cast<const TextureCube *>(this)->levels;
+       const TextureCube &self = *static_cast<const TextureCube *>(this);
 
-       size_t level_size = size*size*get_pixel_size(storage_fmt);
+       size_t level_size = self.size*self.size*get_pixel_size(storage_fmt);
        size_t total_size = level_size;
-       for(unsigned i=0; i<levels; ++i, level_size>>=2)
+       for(unsigned i=0; i<self.levels; ++i, level_size>>=2)
                total_size += level_size;
        return total_size;
 }