]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/texturecube_backend.cpp
Store the number of mipmap levels in the Texture base class
[libs/gl.git] / source / backends / opengl / texturecube_backend.cpp
index 142e343dd9984bb881148ee3dd66739c9cddf3e3..e363f6fb50c77f25a687942f8bea484d2c77ef36 100644 (file)
@@ -37,11 +37,11 @@ void OpenGLTextureCube::allocate()
        if(ARB_texture_storage)
        {
                if(ARB_direct_state_access)
-                       glTextureStorage2D(id, self.levels, gl_fmt, self.size, self.size);
+                       glTextureStorage2D(id, n_levels, gl_fmt, self.size, self.size);
                else
                {
                        bind_scratch();
-                       glTexStorage2D(target, self.levels, gl_fmt, self.size, self.size);
+                       glTexStorage2D(target, n_levels, gl_fmt, self.size, self.size);
                }
        }
        else
@@ -49,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<self.levels; ++i)
+               for(unsigned i=0; i<n_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, self.levels-1);
+               glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, n_levels-1);
        }
 
        apply_swizzle();
@@ -83,7 +83,7 @@ size_t OpenGLTextureCube::get_data_size() const
 
        size_t level_size = self.size*self.size*get_pixel_size(storage_fmt);
        size_t total_size = level_size;
-       for(unsigned i=0; i<self.levels; ++i, level_size>>=2)
+       for(unsigned i=0; i<n_levels; ++i, level_size>>=2)
                total_size += level_size;
        return total_size;
 }