X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftexture2d.cpp;h=2ea713eb3a539c9705e13f90b2775ff9b643fdfd;hb=bdced13c0814d1a860573a0ac19964da2ac4d5e1;hp=f36cadae09aaa21f6abd7f97729d16bf34f6d714;hpb=9d696772b2194b67d8e3e4da11169900eab58c0d;p=libs%2Fgl.git diff --git a/source/texture2d.cpp b/source/texture2d.cpp index f36cadae..2ea713eb 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -32,6 +32,7 @@ public: Texture2D::Texture2D(ResourceManager *m): Texture(GL_TEXTURE_2D, m), + ifmt(RGB), width(0), height(0), allocated(0) @@ -139,10 +140,17 @@ 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); id = 0; + // TODO check which params actually need refreshing + dirty_params = -1; } @@ -199,10 +207,7 @@ Texture2D::AsyncLoader::AsyncLoader(Texture2D &t, IO::Seekable &i): pixel_buffer(PIXEL_UNPACK_BUFFER), mapped_address(0), phase(0) -{ - if(!texture.id) - glGenTextures(1, &texture.id); -} +{ } bool Texture2D::AsyncLoader::needs_sync() const { @@ -237,6 +242,8 @@ bool Texture2D::AsyncLoader::process() return false; } + if(!texture.id) + glGenTextures(1, &texture.id); texture.image(image, false, true); }