X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexture2d_backend.cpp;h=45ba78cc8f6f10c1e4e8d3b7d372b82b148843f0;hp=578cefe390f0a2ec2bfa4bdb15e73426fef43822;hb=6080120777fdf7b6e1184288eff9d205ca7ebf5f;hpb=b274dc87db4422498e72823649358114dfca0096 diff --git a/source/backends/opengl/texture2d_backend.cpp b/source/backends/opengl/texture2d_backend.cpp index 578cefe3..45ba78cc 100644 --- a/source/backends/opengl/texture2d_backend.cpp +++ b/source/backends/opengl/texture2d_backend.cpp @@ -95,11 +95,27 @@ void OpenGLTexture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsig glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } -Resource::AsyncLoader *OpenGLTexture2D::create_async_loader(IO::Seekable &io) +Resource::AsyncLoader *OpenGLTexture2D::load(IO::Seekable &io, const Resources *) { return new AsyncLoader(static_cast(*this), io); } +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; + + size_t level_size = width*height*get_pixel_size(format); + size_t total_size = level_size; + for(unsigned i=0; i>=2) + total_size += level_size; + return total_size; +} + void OpenGLTexture2D::unload() { glDeleteTextures(1, &id); @@ -151,7 +167,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)