]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/texturecube_backend.cpp
Add support for padding in vertex formats
[libs/gl.git] / source / backends / opengl / texturecube_backend.cpp
index cc8945896fea9bdaad6763e4eedda5af50df859c..1cc3f8377f23eaf3027d8e54caeb58f83dbefd7b 100644 (file)
@@ -32,7 +32,7 @@ void OpenGLTextureCube::allocate()
        unsigned levels = static_cast<const TextureCube *>(this)->levels;
 
        if(!id)
-               generate_id();
+               create();
 
        GLenum gl_fmt = get_gl_pixelformat(storage_fmt);
        if(ARB_texture_storage)
@@ -75,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<const TextureCube *>(this)->size;
+       unsigned levels = static_cast<const TextureCube *>(this)->levels;
+
+       size_t level_size = size*size*get_pixel_size(storage_fmt);
+       size_t total_size = level_size;
+       for(unsigned i=0; i<levels; ++i, level_size>>=2)
+               total_size += level_size;
+       return total_size;
+}
+
+
 unsigned get_gl_cube_face(unsigned face)
 {
        switch(static_cast<TextureCubeFace>(face))