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();
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
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();
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;
}