GLint width, GLint height,
GLint destx, GLint desty )
{
- const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
- struct gl_renderbuffer *readRb
- = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *readRb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ const GLfloat depthMax = fb->_DepthMaxF;
GLfloat *p, *tmpImage;
GLint sy, dy, stepy;
GLint i, j;
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
- if (!ctx->Visual.depthBits) {
+ if (fb->Visual.depthBits == 0) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
span.x = destx;
span.y = dy;
span.end = width;
- if (ctx->Visual.rgbMode) {
+ if (fb->Visual.rgbMode) {
if (zoom)
_swrast_write_zoomed_rgba_span( ctx, &span,
(const GLchan (*)[4])span.array->rgba, desty, 0 );
GLint width, GLint height,
GLint destx, GLint desty )
{
- struct gl_renderbuffer *rb
- = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
GLint sy, dy, stepy;
GLint j;
GLstencil *p, *tmpImage;
const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
GLint overlapping;
- if (!ctx->Visual.stencilBits) {
+ if (fb->Visual.stencilBits == 0) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
return;
}
- if (ctx->Visual.stencilBits == 0) {
- _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawPixels(no stencil buffer)");
+ if (ctx->DrawBuffer->Visual.stencilBits == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(no stencil buffer)");
return;
}
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels )
{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
const GLint desty = y;
_swrast_span_default_texcoords(ctx, &span);
if (type == GL_UNSIGNED_SHORT
- && ctx->Visual.depthBits == 16
+ && fb->Visual.depthBits == 16
&& !bias_or_scale
&& !zoom
&& ctx->Visual.rgbMode
&& !zoom
&& ctx->Visual.rgbMode
&& width <= MAX_WIDTH) {
- /* Special case: shift 32-bit values down to ctx->Visual.depthBits */
- const GLint shift = 32 - ctx->Visual.depthBits;
+ /* Special case: shift 32-bit values down to Visual.depthBits */
+ const GLint shift = 32 - fb->Visual.depthBits;
GLint row, spanY = y;
for (row = 0; row < height; row++, spanY++) {
const GLuint *zSrc = (const GLuint *)
GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
- struct gl_renderbuffer *rb
- = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
GLboolean bias_or_scale;
/* clipping should have been done already */
ASSERT(width <= MAX_WIDTH);
/* Error checking */
- if (ctx->Visual.depthBits <= 0) {
+ if (fb->Visual.depthBits <= 0) {
/* No depth buffer */
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels" );
return;
bias_or_scale = ctx->Pixel.DepthBias != 0.0 || ctx->Pixel.DepthScale != 1.0;
- if (type == GL_UNSIGNED_SHORT && ctx->Visual.depthBits == 16
+ if (type == GL_UNSIGNED_SHORT && fb->Visual.depthBits == 16
&& !bias_or_scale && !packing->SwapBytes) {
/* Special case: directly read 16-bit unsigned depth values. */
GLint j;
rb->GetRow(ctx, rb, width, x, y, dest);
}
}
- else if (type == GL_UNSIGNED_INT && ctx->Visual.depthBits == 32
+ else if (type == GL_UNSIGNED_INT && fb->Visual.depthBits == 32
&& !bias_or_scale && !packing->SwapBytes) {
/* Special case: directly read 32-bit unsigned depth values. */
GLint j;
GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
- struct gl_renderbuffer *rb
- = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
GLint j;
if (!rb) {
return;
}
- if (ctx->Visual.stencilBits <= 0) {
+ if (fb->Visual.stencilBits <= 0) {
/* No stencil buffer */
_mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels" );
return;
GLenum format, GLenum type, GLvoid *pixels,
const struct gl_pixelstore_attrib *packing )
{
- struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
+ struct gl_renderbuffer *rb = fb->_ColorReadBuffer;
if (!rb) {
/* No readbuffer is OK with GL_EXT_framebuffer_object */
dest = tmpImage;
for (row = 0; row < height; row++, y++) {
GLchan rgba[MAX_WIDTH][4];
- if (ctx->Visual.rgbMode) {
+ if (fb->Visual.rgbMode) {
_swrast_read_rgba_span(ctx, rb, width, x, y, rgba);
}
else {
for (row = 0; row < height; row++, y++) {
GLchan rgba[MAX_WIDTH][4];
GLvoid *dst;
- if (ctx->Visual.rgbMode) {
+ if (fb->Visual.rgbMode) {
_swrast_read_rgba_span(ctx, rb, width, x, y, rgba);
}
else {
}
dst = _mesa_image_address2d(packing, pixels, width, height,
format, type, row, 0);
- if (ctx->Visual.redBits < CHAN_BITS ||
- ctx->Visual.greenBits < CHAN_BITS ||
- ctx->Visual.blueBits < CHAN_BITS) {
+ if (fb->Visual.redBits < CHAN_BITS ||
+ fb->Visual.greenBits < CHAN_BITS ||
+ fb->Visual.blueBits < CHAN_BITS) {
/* Requantize the color values into floating point and go from
* there. This fixes conformance failures with 16-bit color
* buffers, for example.