X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcore%2Ftexture2d.cpp;h=70a9528d9af9b030dec83c6c88f18dfedce47bd4;hb=3c0cbf0529aa06d9809ad3aa9e282400e8209b4d;hp=31d7016574b17ecdf3200d587f781d940914d21e;hpb=ada4b7614137221b64a00f31fde1498064e9fb19;p=libs%2Fgl.git diff --git a/source/core/texture2d.cpp b/source/core/texture2d.cpp index 31d70165..70a9528d 100644 --- a/source/core/texture2d.cpp +++ b/source/core/texture2d.cpp @@ -4,7 +4,6 @@ #include #include "buffer.h" #include "error.h" -#include "resources.h" #include "texture2d.h" using namespace std; @@ -113,19 +112,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) { - unsigned w = img.get_width(); - unsigned h = img.get_height(); - PixelFormat fmt = pixelformat_from_image(img); - storage(make_pixelformat(get_components(fmt), get_component_type(fmt), use_srgb_format), w, h, lv); - - image(0, from_buffer ? 0 : img.get_pixels()); + storage(pixelformat_from_image(img, use_srgb_format), img.get_width(), img.get_height(), lv); + image(0, img.get_pixels()); } unsigned Texture2D::get_n_levels() const @@ -252,9 +249,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(); }