X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexture2d_backend.cpp;h=54c82280e5b1a0e3e30b0e51bc7a1da6abf28ff6;hb=3b98e13c823d4cb7e4d2d4d14e8440b44bc71f91;hp=2f396df4180978ec52821ec59247ed5a76293be4;hpb=e2a707feb62c5df69884cca34d099dd2f7b7e4e2;p=libs%2Fgl.git diff --git a/source/backends/opengl/texture2d_backend.cpp b/source/backends/opengl/texture2d_backend.cpp index 2f396df4..54c82280 100644 --- a/source/backends/opengl/texture2d_backend.cpp +++ b/source/backends/opengl/texture2d_backend.cpp @@ -41,9 +41,7 @@ OpenGLTexture2D::OpenGLTexture2D(): void OpenGLTexture2D::allocate() { - unsigned width = static_cast(this)->width; - unsigned height = static_cast(this)->height; - unsigned levels = static_cast(this)->levels; + const Texture2D &self = *static_cast(this); if(!id) create(); @@ -52,22 +50,22 @@ void OpenGLTexture2D::allocate() if(ARB_texture_storage) { if(ARB_direct_state_access) - glTextureStorage2D(id, levels, gl_fmt, width, height); + glTextureStorage2D(id, self.levels, gl_fmt, self.width, self.height); else { bind_scratch(); - glTexStorage2D(target, levels, gl_fmt, width, height); + glTexStorage2D(target, self.levels, gl_fmt, self.width, self.height); } } 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); + auto lv_size = self.get_level_size(i); glTexImage2D(target, i, gl_fmt, lv_size.x, lv_size.y, 0, comp, type, 0); } } @@ -105,13 +103,11 @@ uint64_t OpenGLTexture2D::get_data_size() const if(!id) return 0; - unsigned width = static_cast(this)->width; - unsigned height = static_cast(this)->height; - unsigned levels = static_cast(this)->levels; + const Texture2D &self = *static_cast(this); - size_t level_size = width*height*get_pixel_size(format); + size_t level_size = self.width*self.height*get_pixel_size(format); 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; } @@ -167,7 +163,7 @@ bool OpenGLTexture2D::AsyncLoader::process() } else if(phase==1) { - pixel_buffer.storage(n_bytes); + pixel_buffer.storage(n_bytes, STREAMING); mapped_address = reinterpret_cast(pixel_buffer.map()); } else if(phase==2)