-/* $Id: s_readpix.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "feedback.h"
#include "image.h"
#include "macros.h"
-#include "mem.h"
+#include "imports.h"
#include "pixel.h"
#include "s_alphabuf.h"
return;
}
+ if (type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels(index type)");
+ return;
+ }
+
_swrast_use_read_buffer(ctx);
readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
GLushort *dst = (GLushort*) _mesa_image_address( packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 );
GLint i;
- _mesa_read_depth_span(ctx, width, x, y, depth);
+ _swrast_read_depth_span(ctx, width, x, y, depth);
for (i = 0; i < width; i++)
dst[i] = depth[i];
}
for (j=0;j<height;j++,y++) {
GLdepth *dst = (GLdepth *) _mesa_image_address( packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 );
- _mesa_read_depth_span(ctx, width, x, y, dst);
+ _swrast_read_depth_span(ctx, width, x, y, dst);
}
}
else {
GLfloat depth[MAX_WIDTH];
GLvoid *dest;
- _mesa_read_depth_span_float(ctx, readWidth, x, y, depth);
+ _swrast_read_depth_span_float(ctx, readWidth, x, y, depth);
dest = _mesa_image_address(packing, pixels, width, height,
GL_DEPTH_COMPONENT, type, 0, j, 0);
GLvoid *dest;
GLstencil stencil[MAX_WIDTH];
- _mesa_read_stencil_span(ctx, readWidth, x, y, stencil);
+ _swrast_read_stencil_span(ctx, readWidth, x, y, stencil);
dest = _mesa_image_address(packing, pixels, width, height,
GL_STENCIL_INDEX, type, 0, j, 0);
if (0) {
#endif
GLchan *dest = (GLchan *) pixels
- + (skipRows * rowLength + skipPixels) * 4;
+ + (skipRows * rowLength + skipPixels) * 4;
GLint row;
+
+ if (packing->Invert) {
+ /* start at top and go down */
+ dest += (readHeight - 1) * rowLength * 4;
+ rowLength = -rowLength;
+ }
+
for (row=0; row<readHeight; row++) {
(*swrast->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY,
(GLchan (*)[4]) dest);
if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) {
- _mesa_read_alpha_span(ctx, readWidth, srcX, srcY,
+ _swrast_read_alpha_span(ctx, readWidth, srcX, srcY,
(GLchan (*)[4]) dest);
}
dest += rowLength * 4;
for (row = 0; row < height; row++, y++) {
GLchan rgba[MAX_WIDTH][4];
if (ctx->Visual.rgbMode) {
- _mesa_read_rgba_span(ctx, ctx->ReadBuffer, readWidth, x, y, rgba);
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer, readWidth, x, y, rgba);
}
else {
GLuint index[MAX_WIDTH];
GLchan rgba[MAX_WIDTH][4];
GLvoid *dst;
if (ctx->Visual.rgbMode) {
- _mesa_read_rgba_span(ctx, ctx->ReadBuffer, readWidth, x, y, rgba);
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer, readWidth, x, y, rgba);
}
else {
GLuint index[MAX_WIDTH];