Read an RGBA image from the frame buffer. This is used by glCopyTex[Sub]Image[12]D().
- Parameters:
-
| x | window source x |
| y | window source y |
| width | image width |
| height | image height |
| type | datatype for returned GL_RGBA image |
- Returns:
- pointer to image
Definition at line 67 of file s_texstore.c.
Referenced by _swrast_copy_teximage1d(), _swrast_copy_teximage2d(), _swrast_copy_texsubimage1d(), _swrast_copy_texsubimage2d(), and _swrast_copy_texsubimage3d().
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
const GLint pixelSize = _mesa_bytes_per_pixel(GL_RGBA, type);
const GLint stride = width * pixelSize;
GLint row;
GLubyte *image, *dst;
image = (GLubyte *) _mesa_malloc(width * height * pixelSize);
if (!image)
return NULL;
RENDER_START(swrast, ctx);
dst = image;
for (row = 0; row < height; row++) {
_swrast_read_rgba_span(ctx, rb, width, x, y + row, type, dst);
dst += stride;
}
RENDER_FINISH(swrast, ctx);
return image;
}