X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fopengl%2Ftexture2d_backend.cpp;h=9efc4351e65b47e8c6a08dda88d5cb3d344e4565;hb=710363bade528b5015a7c472db3aa90eb08207ab;hp=71a998dcd31187585fd266c1c5e4b19d1369917d;hpb=160e9eea29bd10034733d59507fa1bcca36be401;p=libs%2Fgl.git diff --git a/source/backends/opengl/texture2d_backend.cpp b/source/backends/opengl/texture2d_backend.cpp index 71a998dc..9efc4351 100644 --- a/source/backends/opengl/texture2d_backend.cpp +++ b/source/backends/opengl/texture2d_backend.cpp @@ -16,11 +16,11 @@ private: Texture2D &texture; IO::Seekable &io; Buffer pixel_buffer; - char *mapped_address; + char *mapped_address = 0; Graphics::Image image; - Graphics::ImageLoader *img_loader; - unsigned n_bytes; - int phase; + Graphics::ImageLoader *img_loader = 0; + unsigned n_bytes = 0; + int phase = 0; public: AsyncLoader(Texture2D &, IO::Seekable &); @@ -31,8 +31,8 @@ public: }; -OpenGLTexture2D::OpenGLTexture2D(ResourceManager *m): - Texture(GL_TEXTURE_2D, m) +OpenGLTexture2D::OpenGLTexture2D(): + Texture(GL_TEXTURE_2D) { } void OpenGLTexture2D::allocate() @@ -41,6 +41,9 @@ void OpenGLTexture2D::allocate() unsigned height = static_cast(this)->height; unsigned levels = static_cast(this)->levels; + if(!id) + create(); + GLenum gl_fmt = get_gl_pixelformat(storage_fmt); if(ARB_texture_storage) { @@ -103,9 +106,7 @@ void OpenGLTexture2D::unload() OpenGLTexture2D::AsyncLoader::AsyncLoader(Texture2D &t, IO::Seekable &i): texture(t), io(i), - mapped_address(0), - img_loader(Graphics::ImageLoader::open_io(io)), - phase(0) + img_loader(Graphics::ImageLoader::open_io(io)) { } OpenGLTexture2D::AsyncLoader::~AsyncLoader() @@ -144,7 +145,7 @@ bool OpenGLTexture2D::AsyncLoader::process() } if(!texture.id) - texture.generate_id(); + texture.create(); unsigned w = image.get_width(); unsigned h = image.get_height();