X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexture1d_backend.cpp;h=b8424872b37c3ee960801bfda52eddd4f4185611;hb=e70662d7812464159f2e47f4bebb69d88f89ae93;hp=e44ceb4e757d6efefc4b54414d396894d8a9f019;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/backends/opengl/texture1d_backend.cpp b/source/backends/opengl/texture1d_backend.cpp index e44ceb4e..b8424872 100644 --- a/source/backends/opengl/texture1d_backend.cpp +++ b/source/backends/opengl/texture1d_backend.cpp @@ -19,6 +19,9 @@ void OpenGLTexture1D::allocate() unsigned width = static_cast(this)->width; unsigned levels = static_cast(this)->levels; + if(!id) + create(); + GLenum gl_fmt = get_gl_pixelformat(storage_fmt); if(ARB_texture_storage) { @@ -59,5 +62,20 @@ void OpenGLTexture1D::sub_image(unsigned level, int x, unsigned wd, const void * } } +size_t OpenGLTexture1D::get_data_size() const +{ + if(!id) + return 0; + + unsigned width = static_cast(this)->width; + unsigned levels = static_cast(this)->levels; + + size_t level_size = width*get_pixel_size(storage_fmt); + size_t total_size = level_size; + for(unsigned i=0; i>=2) + total_size += level_size; + return total_size; +} + } // namespace GL } // namespace Msp