-/* $Id: extensions.c,v 1.79 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: extensions.c,v 1.80 2002/09/21 17:34:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
{ ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
{ OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
{ OFF, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate) },
+ { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
{ OFF, "GL_MESA_packed_depth_stencil", 0 },
{ OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
{ OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
"GL_HP_occlusion_test",
"GL_IBM_texture_mirrored_repeat",
"GL_INGR_blend_func_separate",
+ "GL_MESA_pack_invert",
"GL_MESA_resize_buffers",
"GL_MESA_ycbcr_texture",
"GL_NV_blend_square",
-/* $Id: get.c,v 1.90 2002/09/06 13:00:50 brianp Exp $ */
+/* $Id: get.c,v 1.91 2002/09/21 17:34:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
case GL_PACK_IMAGE_HEIGHT_EXT:
*params = ctx->Pack.ImageHeight;
break;
+ case GL_PACK_INVERT_MESA:
+ *params = ctx->Pack.Invert;
+ break;
case GL_PERSPECTIVE_CORRECTION_HINT:
*params = ENUM_TO_BOOL(ctx->Hint.PerspectiveCorrection);
break;
case GL_PACK_IMAGE_HEIGHT_EXT:
*params = (GLdouble) ctx->Pack.ImageHeight;
break;
+ case GL_PACK_INVERT_MESA:
+ *params = (GLdouble) ctx->Pack.Invert;
+ break;
case GL_PERSPECTIVE_CORRECTION_HINT:
*params = ENUM_TO_DOUBLE(ctx->Hint.PerspectiveCorrection);
break;
case GL_PACK_IMAGE_HEIGHT_EXT:
*params = (GLfloat) ctx->Pack.ImageHeight;
break;
+ case GL_PACK_INVERT_MESA:
+ *params = (GLfloat) ctx->Pack.Invert;
+ break;
case GL_PERSPECTIVE_CORRECTION_HINT:
*params = ENUM_TO_FLOAT(ctx->Hint.PerspectiveCorrection);
break;
case GL_PACK_IMAGE_HEIGHT_EXT:
*params = ctx->Pack.ImageHeight;
break;
+ case GL_PACK_INVERT_MESA:
+ *params = ctx->Pack.Invert;
+ break;
case GL_PERSPECTIVE_CORRECTION_HINT:
*params = (GLint) ctx->Hint.PerspectiveCorrection;
break;
-/* $Id: image.c,v 1.67 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: image.c,v 1.68 2002/09/21 17:34:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
0, /* SkipImages */
GL_FALSE, /* SwapBytes */
GL_FALSE, /* LsbFirst */
- GL_FALSE /* ClientStorage */
+ GL_FALSE, /* ClientStorage */
+ GL_FALSE /* Invert */
};
else {
/* Non-BITMAP data */
GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image;
+ GLint topOfImage;
bytes_per_pixel = _mesa_bytes_per_pixel( format, type );
bytes_per_image = bytes_per_row * rows_per_image;
+ if (packing->Invert) {
+ /* set pixel_addr to the last row */
+ topOfImage = bytes_per_row * (height - 1);
+ bytes_per_row = -bytes_per_row;
+ }
+ else {
+ topOfImage = 0;
+ }
+
/* compute final pixel address */
pixel_addr = (GLubyte *) image
+ (skipimages + img) * bytes_per_image
+ + topOfImage
+ (skiprows + row) * bytes_per_row
+ (skippixels + column) * bytes_per_pixel;
}
ASSERT(packing);
if (type == GL_BITMAP) {
/* BITMAP data */
+ GLint bytes;
if (packing->RowLength == 0) {
- GLint bytes = (width + 7) / 8;
- return bytes;
+ bytes = (width + 7) / 8;
}
else {
- GLint bytes = (packing->RowLength + 7) / 8;
- return bytes;
+ bytes = (packing->RowLength + 7) / 8;
+ }
+ if (packing->Invert) {
+ /* negate the bytes per row (negative row stride) */
+ bytes = -bytes;
}
+ return bytes;
}
else {
/* Non-BITMAP data */
remainder = bytesPerRow % packing->Alignment;
if (remainder > 0)
bytesPerRow += (packing->Alignment - remainder);
+ if (packing->Invert)
+ bytesPerRow = -bytesPerRow;
return bytesPerRow;
}
}
-/* $Id: mtypes.h,v 1.86 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: mtypes.h,v 1.87 2002/09/21 17:34:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
GLboolean SwapBytes;
GLboolean LsbFirst;
GLboolean ClientStorage; /* GL_APPLE_client_storage */
+ GLboolean Invert; /* GL_MESA_pack_invert */
};
GLboolean HP_occlusion_test;
GLboolean IBM_rasterpos_clip;
GLboolean INGR_blend_func_separate;
+ GLboolean MESA_pack_invert;
GLboolean MESA_window_pos;
GLboolean MESA_resize_buffers;
GLboolean MESA_ycbcr_texture;
-/* $Id: pixel.c,v 1.35 2002/09/21 16:51:25 brianp Exp $ */
+/* $Id: pixel.c,v 1.36 2002/09/21 17:34:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
ctx->Pack.Alignment = param;
break;
+ case GL_PACK_INVERT_MESA:
+ if (!ctx->Extensions.MESA_pack_invert) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" );
+ return;
+ }
+ if (ctx->Pack.Invert == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.Invert = param;
+ break;
+
case GL_UNPACK_SWAP_BYTES:
if (param == (GLint)ctx->Unpack.SwapBytes)
return;
-/* $Id: s_readpix.c,v 1.15 2002/07/09 01:22:52 brianp Exp $ */
+/* $Id: s_readpix.c,v 1.16 2002/09/21 17:34:56 brianp Exp $ */
/*
* Mesa 3-D graphics library
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);