diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/mtypes.h | 5 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_bitmap.c | 13 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 48 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 18 |
5 files changed, 61 insertions, 27 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d82d806cc8f..4dfdbe46196 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.43 2001/05/29 15:23:49 brianp Exp $ */ +/* $Id: mtypes.h,v 1.44 2001/05/30 15:22:04 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -312,6 +312,7 @@ struct gl_current_attrib { GLuint RasterIndex; /* Current raster index */ GLfloat *RasterTexCoord; /* Current raster texcoord*/ GLfloat RasterMultiTexCoord[MAX_TEXTURE_UNITS][4]; + GLfloat RasterFogCoord; GLboolean RasterPosValid; /* Raster po valid flag */ }; @@ -424,7 +425,7 @@ struct gl_fog_attrib { GLfloat Index; /* Fog index */ GLenum Mode; /* Fog mode */ GLboolean ColorSumEnabled; - GLenum FogCoordinateSource; + GLenum FogCoordinateSource; /* GL_EXT_fog_coord */ }; diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index 388f8f3e28f..958cf23bfb8 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -1,4 +1,4 @@ -/* $Id: rastpos.c,v 1.24 2001/05/01 07:25:41 keithw Exp $ */ +/* $Id: rastpos.c,v 1.25 2001/05/30 15:22:04 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -320,7 +320,7 @@ raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) ctx->Current.RasterPos[3] = clip[3]; ctx->Current.RasterPosValid = GL_TRUE; - /* FOG??? */ + ctx->Current.RasterFogCoord = ctx->Current.FogCoord; { GLuint texSet; diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index aee5f7a0885..0c4592bc871 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -1,4 +1,4 @@ -/* $Id: s_bitmap.c,v 1.9 2001/05/09 17:21:51 brianp Exp $ */ +/* $Id: s_bitmap.c,v 1.10 2001/05/30 15:22:05 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -74,10 +74,15 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, fragZ = (GLdepth) ( ctx->Current.RasterPos[2] * ctx->DepthMaxF); - if (ctx->Fog.Enabled) - _mesa_win_fog_coords_from_z( ctx, 1, &fragZ, &fogCoord ); - else + if (ctx->Fog.Enabled) { + if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) + fogCoord = ctx->Current.FogCoord; + else + fogCoord = ctx->Current.RasterDistance; + } + else { fogCoord = 0.0; + } for (row=0; row<height; row++) { const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack, diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index a4a34ba5925..f9d84975a58 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -1,4 +1,4 @@ -/* $Id: s_copypix.c,v 1.18 2001/05/16 20:27:12 brianp Exp $ */ +/* $Id: s_copypix.c,v 1.19 2001/05/30 15:22:05 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -98,6 +98,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLdepth zspan[MAX_WIDTH]; + GLfloat fogSpan[MAX_WIDTH]; GLboolean quick_draw; GLint row; GLboolean changeBuffer; @@ -108,11 +109,13 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ - GLdepth z = (GLdepth) - (ctx->Current.RasterPos[2] * ctx->DepthMax); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax); + GLfloat fog = (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ? + ctx->Current.RasterFogCoord : ctx->Current.RasterDistance; GLint i; for (i = 0; i < width; i++) { zspan[i] = z; + fogSpan[i] = fog; } } @@ -282,11 +285,11 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, (const GLchan (*)[4])rgba, NULL ); } else if (zoom) { - _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 0, + _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, fogSpan, (const GLchan (*)[4])rgba, desty); } else { - _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, + _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba, NULL, GL_BITMAP ); } } @@ -304,6 +307,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLdepth zspan[MAX_WIDTH]; + GLfloat fogSpan[MAX_WIDTH]; GLchan rgba[MAX_WIDTH][4]; GLchan *tmpImage,*p; GLboolean quick_draw; @@ -340,8 +344,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax); + GLfloat fog = (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ? + ctx->Current.RasterFogCoord : ctx->Current.RasterDistance; for (i=0;i<width;i++) { zspan[i] = z; + fogSpan[i] = fog; } } @@ -543,11 +550,11 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, (const GLchan (*)[4])rgba, NULL ); } else if (zoom) { - _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 0, + _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, fogSpan, (const GLchan (*)[4])rgba, desty); } else { - _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, rgba, + _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba, NULL, GL_BITMAP ); } } @@ -567,6 +574,7 @@ static void copy_ci_pixels( GLcontext *ctx, { SWcontext *swrast = SWRAST_CONTEXT(ctx); GLdepth zspan[MAX_WIDTH]; + GLfloat fogSpan[MAX_WIDTH]; GLuint *tmpImage,*p; GLint sy, dy, stepy; GLint i, j; @@ -595,8 +603,11 @@ static void copy_ci_pixels( GLcontext *ctx, if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMax); + GLfloat fog = (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ? + ctx->Current.RasterFogCoord : ctx->Current.RasterDistance; for (i=0;i<width;i++) { zspan[i] = z; + fogSpan[i] = fog; } } @@ -658,11 +669,11 @@ static void copy_ci_pixels( GLcontext *ctx, } if (zoom) { - _mesa_write_zoomed_index_span(ctx, width, destx, dy, zspan, 0, + _mesa_write_zoomed_index_span(ctx, width, destx, dy, zspan, fogSpan, indexes, desty ); } else { - _mesa_write_index_span(ctx, width, destx, dy, zspan, 0, indexes, + _mesa_write_index_span(ctx, width, destx, dy, zspan, fogSpan, indexes, NULL, GL_BITMAP); } } @@ -686,6 +697,7 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, { GLfloat depth[MAX_WIDTH]; GLdepth zspan[MAX_WIDTH]; + GLfloat fogSpan[MAX_WIDTH]; GLfloat *p, *tmpImage; GLuint indexes[MAX_WIDTH]; GLint sy, dy, stepy; @@ -732,6 +744,14 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } } + if (ctx->Fog.Enabled) { + GLfloat fog = (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ? + ctx->Current.RasterFogCoord : ctx->Current.RasterDistance; + for (i = 0; i < width; i++) { + fogSpan[i] = fog; + } + } + if (overlapping) { GLint ssy = sy; tmpImage = (GLfloat *) MALLOC(width * height * sizeof(GLfloat)); @@ -768,22 +788,22 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, if (ctx->Visual.rgbMode) { if (zoom) { - _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, 0, - (const GLchan (*)[4])rgba, desty ); + _mesa_write_zoomed_rgba_span( ctx, width, destx, dy, zspan, + fogSpan, (const GLchan (*)[4])rgba, desty ); } else { - _mesa_write_rgba_span( ctx, width, destx, dy, zspan, 0, + _mesa_write_rgba_span( ctx, width, destx, dy, zspan, fogSpan, rgba, NULL, GL_BITMAP); } } else { if (zoom) { _mesa_write_zoomed_index_span( ctx, width, destx, dy, - zspan, 0, indexes, desty ); + zspan, fogSpan, indexes, desty ); } else { _mesa_write_index_span( ctx, width, destx, dy, - zspan, 0, indexes, NULL, GL_BITMAP ); + zspan, fogSpan, indexes, NULL, GL_BITMAP ); } } } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 59b2d0294b3..4ab5a7717ac 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -1,4 +1,4 @@ -/* $Id: s_drawpix.c,v 1.19 2001/05/16 20:27:12 brianp Exp $ */ +/* $Id: s_drawpix.c,v 1.20 2001/05/30 15:22:05 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -490,15 +490,19 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, const GLint desty = y; GLint row, drawWidth; GLdepth zspan[MAX_WIDTH]; + GLfloat fogSpan[MAX_WIDTH]; drawWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width; /* Fragment depth values */ if (ctx->Depth.Test || ctx->Fog.Enabled) { GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMaxF); + GLfloat fog = (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ? + ctx->Current.RasterFogCoord : ctx->Current.RasterDistance; GLint i; for (i = 0; i < drawWidth; i++) { zspan[i] = zval; + fogSpan[i] = fog; } } @@ -513,11 +517,11 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, type, source, &ctx->Unpack, ctx->_ImageTransferState); if (zoom) { - _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, 0, + _mesa_write_zoomed_index_span(ctx, drawWidth, x, y, zspan, fogSpan, indexes, desty); } else { - _mesa_write_index_span(ctx, drawWidth, x, y, zspan, 0, indexes, + _mesa_write_index_span(ctx, drawWidth, x, y, zspan, fogSpan, indexes, NULL, GL_BITMAP); } } @@ -714,6 +718,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLint desty = y; GLdepth zspan[MAX_WIDTH]; + GLfloat fogSpan[MAX_WIDTH]; GLboolean quickDraw; GLfloat *convImage = NULL; GLuint transferOps = ctx->_ImageTransferState; @@ -731,9 +736,12 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->DepthMaxF); + GLfloat fog = (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) ? + ctx->Current.RasterFogCoord : ctx->Current.RasterDistance; GLint i; for (i=0;i<width;i++) { zspan[i] = z; + fogSpan[i] = fog; } } @@ -852,11 +860,11 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, (CONST GLchan (*)[4]) rgba, NULL); } else if (zoom) { - _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, 0, + _mesa_write_zoomed_rgba_span(ctx, width, x, y, zspan, fogSpan, (CONST GLchan (*)[4]) rgba, desty); } else { - _mesa_write_rgba_span(ctx, (GLuint) width, x, y, zspan, 0, + _mesa_write_rgba_span(ctx, (GLuint) width, x, y, zspan, fogSpan, rgba, NULL, GL_BITMAP); } } |