summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-01-03 22:55:26 +0000
committerBrian Paul <[email protected]>2001-01-03 22:55:26 +0000
commitd14fce03f0b5db720cfc52a3c81f407626e28111 (patch)
treea3c372453ea5fb84e6a7561e7a980e25c98a9e9c /src/mesa
parent08dfacd4259b4c6f6d89e4d0c52ade17e811e314 (diff)
added divide by zero checks
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/swrast/s_fog.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c
index 6e6c207aa4a..f103bdb02d4 100644
--- a/src/mesa/swrast/s_fog.c
+++ b/src/mesa/swrast/s_fog.c
@@ -1,4 +1,4 @@
-/* $Id: s_fog.c,v 1.7 2001/01/03 15:59:30 brianp Exp $ */
+/* $Id: s_fog.c,v 1.8 2001/01/03 22:55:26 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -119,9 +119,14 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx,
const GLfloat p10 = ctx->ProjectionMatrix.m[10];
const GLfloat p14 = ctx->ProjectionMatrix.m[14];
const GLfloat tz = ctx->Viewport._WindowMap.m[MAT_TZ];
- const GLfloat szInv = 1.0F / ctx->Viewport._WindowMap.m[MAT_SZ];
+ GLfloat szInv;
GLuint i;
+ if (ctx->Viewport._WindowMap.m[MAT_SZ] == 0.0)
+ szInv = 1.0F;
+ else
+ szInv = 1.0F / ctx->Viewport._WindowMap.m[MAT_SZ];
+
/*
* Note: to compute eyeZ from the ndcZ we have to solve the following:
*
@@ -149,7 +154,11 @@ _mesa_win_fog_coords_from_z( const GLcontext *ctx,
case GL_LINEAR:
{
GLfloat fogEnd = ctx->Fog.End;
- GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ GLfloat fogScale;
+ if (ctx->Fog.Start == ctx->Fog.End)
+ fogScale = 1.0;
+ else
+ fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
if (ortho) {
for (i=0;i<n;i++) {
GLfloat ndcz = ((GLfloat) z[i] - tz) * szInv;