X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexturecube_backend.cpp;h=1cc3f8377f23eaf3027d8e54caeb58f83dbefd7b;hb=8a8cce8ef4ee28b3572a72958b8b407759f9f826;hp=b113f1bd21ba1a13f01effd610d67df8e7e01624;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/backends/opengl/texturecube_backend.cpp b/source/backends/opengl/texturecube_backend.cpp index b113f1bd..1cc3f837 100644 --- a/source/backends/opengl/texturecube_backend.cpp +++ b/source/backends/opengl/texturecube_backend.cpp @@ -31,6 +31,9 @@ void OpenGLTextureCube::allocate() unsigned size = static_cast(this)->size; unsigned levels = static_cast(this)->levels; + if(!id) + create(); + GLenum gl_fmt = get_gl_pixelformat(storage_fmt); if(ARB_texture_storage) { @@ -72,6 +75,22 @@ void OpenGLTextureCube::sub_image(unsigned face, unsigned level, int x, int y, u } } +size_t OpenGLTextureCube::get_data_size() const +{ + if(!id) + return 0; + + unsigned size = static_cast(this)->size; + unsigned levels = static_cast(this)->levels; + + size_t level_size = size*size*get_pixel_size(storage_fmt); + size_t total_size = level_size; + for(unsigned i=0; i>=2) + total_size += level_size; + return total_size; +} + + unsigned get_gl_cube_face(unsigned face) { switch(static_cast(face))