X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Ftexture2d.cpp;h=6edbba0d993a0f3795d264834c43054d5acd23b2;hb=b09f265880a3a932441091b0f3822b06c112c595;hp=703b719a211f6390c78f35aacfe9f12a9c07701b;hpb=8b3e51aeff0e22d29a34772c77b8647108f58677;p=libs%2Fgl.git diff --git a/source/core/texture2d.cpp b/source/core/texture2d.cpp index 703b719a..6edbba0d 100644 --- a/source/core/texture2d.cpp +++ b/source/core/texture2d.cpp @@ -113,15 +113,17 @@ void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht } } -void Texture2D::image(const Graphics::Image &img, unsigned lv) +void Texture2D::sub_image(unsigned level, int x, int y, unsigned wd, unsigned ht, const Buffer &buffer, unsigned offset) { - image(img, lv, false); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer.id); + sub_image(level, x, y, wd, ht, reinterpret_cast(offset)); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); } -void Texture2D::image(const Graphics::Image &img, unsigned lv, bool from_buffer) +void Texture2D::image(const Graphics::Image &img, unsigned lv) { storage(pixelformat_from_image(img, use_srgb_format), img.get_width(), img.get_height(), lv); - image(0, from_buffer ? 0 : img.get_pixels()); + image(0, img.get_pixels()); } unsigned Texture2D::get_n_levels() const @@ -248,9 +250,12 @@ bool Texture2D::AsyncLoader::process() if(!texture.id) texture.generate_id(); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixel_buffer.get_id()); - texture.image(image, 0, true); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + + unsigned w = image.get_width(); + unsigned h = image.get_height(); + texture.storage(pixelformat_from_image(image, texture.use_srgb_format), w, h); + texture.sub_image(0, 0, 0, w, h, pixel_buffer, 0); + if(texture.auto_gen_mipmap) texture.generate_mipmap(); }