glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
-Resource::AsyncLoader *OpenGLTexture2D::create_async_loader(IO::Seekable &io)
+Resource::AsyncLoader *OpenGLTexture2D::load(IO::Seekable &io, const Resources *)
{
return new AsyncLoader(static_cast<Texture2D &>(*this), io);
}
+uint64_t OpenGLTexture2D::get_data_size() const
+{
+ if(!id)
+ return 0;
+
+ unsigned width = static_cast<const Texture2D *>(this)->width;
+ unsigned height = static_cast<const Texture2D *>(this)->height;
+ unsigned levels = static_cast<const Texture2D *>(this)->levels;
+
+ size_t level_size = width*height*get_pixel_size(format);
+ size_t total_size = level_size;
+ for(unsigned i=0; i<levels; ++i, level_size>>=2)
+ total_size += level_size;
+ return total_size;
+}
+
void OpenGLTexture2D::unload()
{
glDeleteTextures(1, &id);