X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexture1d_backend.cpp;h=8e33d278984ca06c8f81c4222e01717d195b5b55;hp=b8424872b37c3ee960801bfda52eddd4f4185611;hb=3b98e13c823d4cb7e4d2d4d14e8440b44bc71f91;hpb=0d89e19481d4d5f770411141906f9df344c6b823 diff --git a/source/backends/opengl/texture1d_backend.cpp b/source/backends/opengl/texture1d_backend.cpp index b8424872..8e33d278 100644 --- a/source/backends/opengl/texture1d_backend.cpp +++ b/source/backends/opengl/texture1d_backend.cpp @@ -16,8 +16,7 @@ OpenGLTexture1D::OpenGLTexture1D(): void OpenGLTexture1D::allocate() { - unsigned width = static_cast(this)->width; - unsigned levels = static_cast(this)->levels; + const Texture1D &self = *static_cast(this); if(!id) create(); @@ -26,22 +25,22 @@ void OpenGLTexture1D::allocate() if(ARB_texture_storage) { if(ARB_direct_state_access) - glTextureStorage1D(id, levels, gl_fmt, width); + glTextureStorage1D(id, self.levels, gl_fmt, self.width); else { bind_scratch(); - glTexStorage1D(target, levels, gl_fmt, width); + glTexStorage1D(target, self.levels, gl_fmt, self.width); } } else { bind_scratch(); - glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, levels-1); + glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, self.levels-1); GLenum comp = get_gl_components(get_components(storage_fmt)); GLenum type = get_gl_type(get_component_type(storage_fmt)); - for(unsigned i=0; i(this)->get_level_size(i); + unsigned lv_size = self.get_level_size(i); glTexImage1D(target, i, gl_fmt, lv_size, 0, comp, type, 0); } } @@ -67,12 +66,11 @@ size_t OpenGLTexture1D::get_data_size() const if(!id) return 0; - unsigned width = static_cast(this)->width; - unsigned levels = static_cast(this)->levels; + const Texture1D &self = *static_cast(this); - size_t level_size = width*get_pixel_size(storage_fmt); + size_t level_size = self.width*get_pixel_size(storage_fmt); size_t total_size = level_size; - for(unsigned i=0; i>=2) + for(unsigned i=0; i>=2) total_size += level_size; return total_size; }