Merge branch 'mesa_7_7_branch'
[mesa.git] / src / mesa / tnl / t_vb_fog.c
index d8bca3820bc8ee7b5a1281e2e0f99ccc232faf1e..4a0e6ad4f997cad65803b2e6663f6339d48bf25e 100644 (file)
  */
 
 
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/context.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/mtypes.h"
 
 #include "math/m_xform.h"
 
@@ -148,15 +148,15 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
    struct fog_stage_data *store = FOG_STAGE_DATA(stage);
    GLvector4f *input;
 
-   if (!ctx->Fog.Enabled || ctx->VertexProgram._Current)
-      return GL_TRUE;
 
+   if (!ctx->Fog.Enabled)
+      return GL_TRUE;
 
-   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
+   if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && !ctx->VertexProgram._Current) {
       GLuint i;
       GLfloat *coord;
       /* Fog is computed from vertex or fragment Z values */
-      /* source = VB->ObjPtr or VB->EyePtr coords */
+      /* source = VB->AttribPtr[_TNL_ATTRIB_POS] or VB->EyePtr coords */
       /* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */
       VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord;
 
@@ -176,11 +176,12 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
         /* Full eye coords weren't required, just calculate the
          * eye Z values.
          */
-        _mesa_dotprod_tab[VB->ObjPtr->size]( (GLfloat *) input->data,
-                                             4 * sizeof(GLfloat),
-                                             VB->ObjPtr, plane );
+        _mesa_dotprod_tab[VB->AttribPtr[_TNL_ATTRIB_POS]->size]
+           ( (GLfloat *) input->data,
+             4 * sizeof(GLfloat),
+             VB->AttribPtr[_TNL_ATTRIB_POS], plane );
 
-        input->count = VB->ObjPtr->count;
+        input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count;
 
         /* make sure coords are really positive
            NOTE should avoid going through array twice */
@@ -213,7 +214,7 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
       /* input->count may be one if glFogCoord was only called once
        * before glBegin.  But we need to compute fog for all vertices.
        */
-      input->count = VB->ObjPtr->count;
+      input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count;
 
       VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord;  /* dest data */
    }
@@ -227,7 +228,6 @@ run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
       VB->AttribPtr[_TNL_ATTRIB_FOG] = input;
    }
 
-   VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
    return GL_TRUE;
 }