]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture2d.cpp
Implement automatic unloading when a total size limit is exceeded
[libs/gl.git] / source / texture2d.cpp
index 2da1c25245b1064cf8da073c8e9c4d919fb9417a..e237e504176ace2bfd56ddf74597907aee397abb 100644 (file)
@@ -32,6 +32,7 @@ public:
 
 Texture2D::Texture2D(ResourceManager *m):
        Texture(GL_TEXTURE_2D, m),
+       ifmt(RGB),
        width(0),
        height(0),
        allocated(0)
@@ -139,6 +140,11 @@ Resource::AsyncLoader *Texture2D::load(IO::Seekable &io)
        return new AsyncLoader(*this, io);
 }
 
+UInt64 Texture2D::get_data_size() const
+{
+       return id ? width*height*get_component_count(ifmt) : 0;
+}
+
 void Texture2D::unload()
 {
        glDeleteTextures(1, &id);