summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_readpixels.c
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-08-13 18:16:11 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-08-13 18:20:04 -0600
commit4698483f849ba8dfde20a5d649f1ea099291f241 (patch)
tree1074039d22618502b72b077182ce55aa2ba089f8 /src/mesa/state_tracker/st_cb_readpixels.c
parentcd308dfa794a1be5d933a4b89539d53929537f88 (diff)
Added st_fb_orientation() function to determine the up/down orientation of the framebuffer.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_readpixels.c')
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 22abc104e2..98604e5b6b 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -60,7 +60,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
struct pipe_context *pipe = ctx->st->pipe;
GLfloat temp[MAX_WIDTH][4];
const GLbitfield transferOps = ctx->_ImageTransferState;
- GLint i, yInv, dfStride;
+ GLint i, yStep, dfStride;
GLfloat *df;
struct st_renderbuffer *strb;
struct gl_pixelstore_attrib clippedPacking = *pack;
@@ -104,11 +104,19 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
dfStride = 0;
}
+ /* determine bottom-to-top vs. top-to-bottom order */
+ if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
+ y = strb->Base.Height - 1 - y;
+ yStep = -1;
+ }
+ else {
+ yStep = 1;
+ }
+
/* Do a row at a time to flip image data vertically */
- yInv = strb->Base.Height - 1 - y;
for (i = 0; i < height; i++) {
- strb->surface->get_tile(strb->surface, x, yInv, width, 1, df);
- yInv--;
+ strb->surface->get_tile(strb->surface, x, y, width, 1, df);
+ y += yStep;
df += dfStride;
if (!dfStride) {
/* convert GLfloat to user's format/type */