From 4ca375e8fe395e375826ea795566b8af8029e09f Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 24 Aug 2009 12:50:57 +0100 Subject: [PATCH] [cogl-texture] Set GL_PACK_ROW_LENGTH when downloading texture data Otherwise the rowstride passed in from an application is not used correctly so you can not download to an area with a much larger rowstride. --- clutter/cogl/gl/cogl-texture.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/clutter/cogl/gl/cogl-texture.c b/clutter/cogl/gl/cogl-texture.c index 7721ea2a8..20000ec35 100644 --- a/clutter/cogl/gl/cogl-texture.c +++ b/clutter/cogl/gl/cogl-texture.c @@ -184,8 +184,16 @@ prep_for_gl_pixels_upload (gint pixels_rowstride, } static void -prep_for_gl_pixels_download (gint pixels_rowstride) +prep_for_gl_pixels_download (gint pixels_rowstride, + gint pixels_src_x, + gint pixels_src_y, + gint pixels_bpp) { + GE( glPixelStorei (GL_PACK_ROW_LENGTH, pixels_rowstride / pixels_bpp) ); + + GE( glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) ); + GE( glPixelStorei (GL_PACK_SKIP_ROWS, pixels_src_y) ); + if (!(pixels_rowstride & 0x7)) GE( glPixelStorei (GL_PACK_ALIGNMENT, 8) ); else if (!(pixels_rowstride & 0x3)) @@ -404,7 +412,7 @@ _cogl_texture_download_from_gl (CoglTexture *tex, slice_bmp.height); /* Setup gl alignment to 0,0 top-left corner */ - prep_for_gl_pixels_download (slice_bmp.rowstride); + prep_for_gl_pixels_download (slice_bmp.rowstride, 0, 0, bpp); /* Download slice image data into temp bmp */ GE( glBindTexture (tex->gl_target, gl_handle) ); @@ -432,7 +440,7 @@ _cogl_texture_download_from_gl (CoglTexture *tex, + x_span->start * bpp + y_span->start * target_bmp->rowstride; - prep_for_gl_pixels_download (target_bmp->rowstride); + prep_for_gl_pixels_download (target_bmp->rowstride, 0, 0, bpp); /* Download slice image data */ GE( glBindTexture (tex->gl_target, gl_handle) );