2 #include <msp/gl/extensions/ext_texture3d.h>
3 #include <msp/gl/extensions/ext_unpack_subimage.h>
5 #include "pixelformat.h"
6 #include "pixelstore.h"
13 PixelStore::PixelStore():
22 PixelStore PixelStore::from_image(const Graphics::Image &img)
25 unsigned stride = img.get_stride();
26 unsigned ncomp = get_component_count(pixelformat_from_image(img));
27 pstore.set_canvas_size(img.get_stride()/ncomp, 0);
28 pstore.set_alignment(min(stride&~(stride-1), 8U));
32 void PixelStore::update_parameter(int mask) const
39 glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
41 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, image_height);
45 glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels);
46 glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows);
48 glPixelStorei(GL_UNPACK_SKIP_IMAGES, skip_images);
51 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
54 void PixelStore::set_canvas_size(unsigned w, unsigned h)
56 static Require _req(EXT_unpack_subimage);
59 update_parameter(SIZE);
62 void PixelStore::set_origin(unsigned x, unsigned y, unsigned z)
64 static Require _req(EXT_unpack_subimage);
66 static Require _req3d(EXT_texture3D);
70 update_parameter(ORIGIN);
73 void PixelStore::set_alignment(unsigned a)
76 update_parameter(ALIGNMENT);
79 void PixelStore::bind() const