diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2002-09-21 17:12:10 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2002-09-21 17:12:10 +0000 |
commit | a53dccf9c5b0eff80849c5d8f76d845f1336794d (patch) | |
tree | c61ed3550f88f243b26d395dc71349ed1c94528b | |
parent | 3291a3c69cb937a72480cd780a6c587dcc485f3c (diff) |
added GL_MESA_pack_invert
-rw-r--r-- | include/GL/gl.h | 11 | ||||
-rw-r--r-- | src/mesa/main/extensions.c | 4 | ||||
-rw-r--r-- | src/mesa/main/get.c | 14 | ||||
-rw-r--r-- | src/mesa/main/image.c | 25 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 4 | ||||
-rw-r--r-- | src/mesa/main/pixel.c | 13 | ||||
-rw-r--r-- | src/mesa/swrast/s_readpix.c | 11 |
7 files changed, 70 insertions, 12 deletions
diff --git a/include/GL/gl.h b/include/GL/gl.h index 720302edfa..bfe56b02f5 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -1,4 +1,4 @@ -/* $Id: gl.h,v 1.59.2.10 2002/09/20 19:41:32 brianp Exp $ */ +/* $Id: gl.h,v 1.59.2.11 2002/09/21 17:12:10 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -2534,6 +2534,15 @@ GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 + +#define GL_PACK_INVERT_MESA 0x8758 + +#endif /* GL_MESA_pack_invert */ + + + #ifndef GL_APPLE_client_storage #define GL_APPLE_client_storage 1 diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index e3bd1540c9..b572bb2b4c 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -1,4 +1,4 @@ -/* $Id: extensions.c,v 1.65.2.5 2002/09/20 19:40:52 brianp Exp $ */ +/* $Id: extensions.c,v 1.65.2.6 2002/09/21 17:12:33 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -103,6 +103,7 @@ static struct { { 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) }, @@ -164,6 +165,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) "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", diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 252bf1b1c8..7f4412effb 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1,4 +1,4 @@ -/* $Id: get.c,v 1.69.2.10 2002/09/13 17:34:17 brianp Exp $ */ +/* $Id: get.c,v 1.69.2.11 2002/09/21 17:12:33 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -672,6 +672,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) 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; @@ -1976,6 +1979,9 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) 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; @@ -3284,6 +3290,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) 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; @@ -4561,6 +4570,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) 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; diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 9fc4c7babb..d0a77857ba 100644 --- a/src/mesa/main/image.c +++ b/src/mesa/main/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.63.2.4 2002/09/20 19:40:53 brianp Exp $ */ +/* $Id: image.c,v 1.63.2.5 2002/09/21 17:12:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -494,6 +494,7 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing, 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 ); @@ -509,9 +510,19 @@ _mesa_image_address( const struct gl_pixelstore_attrib *packing, 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; } @@ -532,14 +543,18 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, 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 */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6442f60298..5084ad6f37 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.51.2.11 2002/09/20 19:40:53 brianp Exp $ */ +/* $Id: mtypes.h,v 1.51.2.12 2002/09/21 17:12:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -993,6 +993,7 @@ struct gl_pixelstore_attrib { GLboolean SwapBytes; GLboolean LsbFirst; GLboolean ClientStorage; /* GL_APPLE_client_storage */ + GLboolean Invert; /* GL_MESA_pack_invert */ }; @@ -1243,6 +1244,7 @@ struct gl_extensions { 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; diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index 175cfe7db4..8cb4f86ac1 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,4 +1,4 @@ -/* $Id: pixel.c,v 1.31.2.3 2002/09/20 19:40:53 brianp Exp $ */ +/* $Id: pixel.c,v 1.31.2.4 2002/09/21 17:12:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -146,6 +146,17 @@ _mesa_PixelStorei( GLenum pname, GLint param ) 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; diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index ed4ae7199c..a9eb6e75ed 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -1,4 +1,4 @@ -/* $Id: s_readpix.c,v 1.12.2.2 2002/04/19 01:10:48 brianp Exp $ */ +/* $Id: s_readpix.c,v 1.12.2.3 2002/09/21 17:12:34 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -282,8 +282,15 @@ read_fast_rgba_pixels( GLcontext *ctx, 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); |