Committing in .
[mesa.git] / src / mesa / tnl / t_vb_fog.c
index b7876a4db9ddd70007809f4c22fbbcca5d215757..6d688ca04126aade8b31ad93e384e8f426a76c38 100644 (file)
@@ -1,10 +1,9 @@
-/* $Id: t_vb_fog.c,v 1.15 2002/01/05 20:51:13 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  5.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -24,7 +23,7 @@
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  * Authors:
- *    Keith Whitwell <keithw@valinux.com>
+ *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
 
@@ -32,8 +31,7 @@
 #include "colormac.h"
 #include "context.h"
 #include "macros.h"
-#include "mem.h"
-#include "mmath.h"
+#include "imports.h"
 #include "mtypes.h"
 
 #include "math/m_xform.h"
@@ -105,14 +103,14 @@ static void make_win_fog_coords( GLcontext *ctx, GLvector4f *out,
       else
          d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
       for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
-         GLfloat f = (end - ABSF(*v)) * d;
+         GLfloat f = (end - FABSF(*v)) * d;
         data[i][0] = CLAMP(f, 0.0F, 1.0F);
       }
       break;
    case GL_EXP:
       d = ctx->Fog.Density;
       for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride))
-         NEG_EXP( data[i][0], d * ABSF(*v) );
+         NEG_EXP( data[i][0], d * FABSF(*v) );
       break;
    case GL_EXP2:
       d = ctx->Fog.Density*ctx->Fog.Density;
@@ -129,7 +127,7 @@ static void make_win_fog_coords( GLcontext *ctx, GLvector4f *out,
 
 
 static GLboolean run_fog_stage( GLcontext *ctx,
-                               struct gl_pipeline_stage *stage )
+                               struct tnl_pipeline_stage *stage )
 {
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
    struct fog_stage_data *store = FOG_STAGE_DATA(stage);
@@ -142,7 +140,7 @@ static GLboolean run_fog_stage( GLcontext *ctx,
       /* fog computed from Z depth */
       /* source = VB->ObjPtr or VB->EyePtr coords */
       /* dest = VB->FogCoordPtr = fog stage private storage */
-      VB->AttribPtr[VERT_ATTRIB_FOG] = &store->fogcoord;
+      VB->FogCoordPtr = &store->fogcoord;
 
       if (!ctx->_NeedEyeCoords) {
         const GLfloat *m = ctx->ModelviewMatrixStack.Top->m;
@@ -181,31 +179,31 @@ static GLboolean run_fog_stage( GLcontext *ctx,
    else {
       /* use glFogCoord() coordinates */
       /* source = VB->FogCoordPtr */
-      input = VB->AttribPtr[VERT_ATTRIB_FOG];
+      input = VB->FogCoordPtr;
       /* dest = fog stage private storage */
-      VB->AttribPtr[VERT_ATTRIB_FOG] = &store->fogcoord;
+      VB->FogCoordPtr = &store->fogcoord;
    }
 
-   make_win_fog_coords( ctx, VB->AttribPtr[VERT_ATTRIB_FOG], input );
+   make_win_fog_coords( ctx, VB->FogCoordPtr, input );
    return GL_TRUE;
 }
 
 
-static void check_fog_stage( GLcontext *ctx, struct gl_pipeline_stage *stage )
+static void check_fog_stage( GLcontext *ctx, struct tnl_pipeline_stage *stage )
 {
    stage->active = ctx->Fog.Enabled && !ctx->VertexProgram.Enabled;
 
    if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
-      stage->inputs = VERT_EYE;
+      stage->inputs = _TNL_BIT_POS;
    else
-      stage->inputs = VERT_FOG_BIT;
+      stage->inputs = _TNL_BIT_FOG;
 }
 
 
 /* Called the first time stage->run() is invoked.
  */
 static GLboolean alloc_fog_data( GLcontext *ctx,
-                                struct gl_pipeline_stage *stage )
+                                struct tnl_pipeline_stage *stage )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct fog_stage_data *store;
@@ -227,7 +225,7 @@ static GLboolean alloc_fog_data( GLcontext *ctx,
 }
 
 
-static void free_fog_data( struct gl_pipeline_stage *stage )
+static void free_fog_data( struct tnl_pipeline_stage *stage )
 {
    struct fog_stage_data *store = FOG_STAGE_DATA(stage);
    if (store) {
@@ -238,14 +236,14 @@ static void free_fog_data( struct gl_pipeline_stage *stage )
 }
 
 
-const struct gl_pipeline_stage _tnl_fog_coordinate_stage =
+const struct tnl_pipeline_stage _tnl_fog_coordinate_stage =
 {
    "build fog coordinates",    /* name */
    _NEW_FOG,                   /* check_state */
    _NEW_FOG,                   /* run_state */
    GL_FALSE,                   /* active? */
    0,                          /* inputs */
-   VERT_FOG_BIT,               /* outputs */
+   _TNL_BIT_FOG,               /* outputs */
    0,                          /* changed_inputs */
    NULL,                       /* private_data */
    free_fog_data,              /* dtr */