X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fbackends%2Fopengl%2Ftexture3d_backend.cpp;h=961dd7e721766596f439312c45d11348e4eaebc7;hb=8a8cce8ef4ee28b3572a72958b8b407759f9f826;hp=1197405ee367ff192690437f37ccca89b677000f;hpb=57ca8f2bd18525d80ed6ad5d3f72e57901162d55;p=libs%2Fgl.git diff --git a/source/backends/opengl/texture3d_backend.cpp b/source/backends/opengl/texture3d_backend.cpp index 1197405e..961dd7e7 100644 --- a/source/backends/opengl/texture3d_backend.cpp +++ b/source/backends/opengl/texture3d_backend.cpp @@ -27,7 +27,7 @@ void OpenGLTexture3D::allocate() unsigned levels = static_cast(this)->levels; if(!id) - generate_id(); + create(); GLenum gl_fmt = get_gl_pixelformat(storage_fmt); if(ARB_texture_storage) @@ -74,5 +74,22 @@ bool OpenGLTexture3D::is_array() const return target==GL_TEXTURE_2D_ARRAY; } +size_t OpenGLTexture3D::get_data_size() const +{ + if(!id) + return 0; + + unsigned width = static_cast(this)->width; + unsigned height = static_cast(this)->height; + unsigned depth = static_cast(this)->depth; + unsigned levels = static_cast(this)->levels; + + size_t level_size = width*height*depth*get_pixel_size(format); + size_t total_size = level_size; + for(unsigned i=0; i>=2) + total_size += level_size; + return total_size; +} + } // namespace GL } // namespace Msp