X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpixelstore.cpp;fp=source%2Fpixelstore.cpp;h=011866e3e72410a44031a0b154367c621bebb44f;hb=126161d1d44ab9503bc747d24a07b7b9d15e527a;hp=c32cf60964a30b43cf7946782fa2c5943231e710;hpb=dcd8bd3a16a4af8e77aa84877b3f8a4fb03b8c7e;p=libs%2Fgl.git diff --git a/source/pixelstore.cpp b/source/pixelstore.cpp index c32cf609..011866e3 100644 --- a/source/pixelstore.cpp +++ b/source/pixelstore.cpp @@ -27,10 +27,31 @@ PixelStore PixelStore::from_image(const Graphics::Image &img) return pstore; } +void PixelStore::update_parameter(int mask) const +{ + if(cur_obj!=this) + return; + + if(mask&SIZE) + { + glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); + glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height); + } + if(mask&ORIGIN) + { + glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); + glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); + glPixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images); + } + if(mask&ALIGNMENT) + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); +} + void PixelStore::set_canvas_size(unsigned w, unsigned h) { row_length = w; image_height = h; + update_parameter(SIZE); } void PixelStore::set_origin(unsigned x, unsigned y, unsigned z) @@ -38,24 +59,19 @@ void PixelStore::set_origin(unsigned x, unsigned y, unsigned z) skip_pixels = x; skip_rows = y; skip_images = z; + update_parameter(ORIGIN); } void PixelStore::set_alignment(unsigned a) { alignment = a; + update_parameter(ALIGNMENT); } void PixelStore::bind() const { if(set_current(this)) - { - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); - glPixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images); - glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); - } + update_parameter(-1); } } // namespace GL