Merge branch 'master' into glsl-pp-rework-2
[mesa.git] / src / mesa / tnl / t_vb_light.c
index 47c5b400aaedebc059ff96d2749cce6a3a03c78f..8a0fe63fd8b75ab60feaa3042c883ae093aa79b8 100644 (file)
 
 
 
-#include "glheader.h"
-#include "colormac.h"
-#include "light.h"
-#include "macros.h"
-#include "imports.h"
-#include "simple_list.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/colormac.h"
+#include "main/light.h"
+#include "main/macros.h"
+#include "main/imports.h"
+#include "main/simple_list.h"
+#include "main/mtypes.h"
 
 #include "math/m_translate.h"
 
@@ -127,7 +127,7 @@ prepare_materials(GLcontext *ctx,
       const GLuint bitmask = ctx->Light.ColorMaterialBitmask;
       for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
         if (bitmask & (1<<i))
-           VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->ColorPtr[0];
+           VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
    }
 
    /* Now, for each material attribute that's tracking vertex color, save
@@ -200,24 +200,21 @@ static GLboolean run_lighting( GLcontext *ctx,
    struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
-   GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr;
+   GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->AttribPtr[_TNL_ATTRIB_POS];
    GLuint idx;
 
-   if (ctx->ShaderObjects._VertexShaderPresent)
-      return GL_TRUE;
-
-   if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
+   if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
       return GL_TRUE;
 
    /* Make sure we can talk about position x,y and z:
     */
-   if (input->size <= 2 && input == VB->ObjPtr) {
+   if (input->size <= 2 && input == VB->AttribPtr[_TNL_ATTRIB_POS]) {
 
       _math_trans_4f( store->Input.data,
-                     VB->ObjPtr->data,
-                     VB->ObjPtr->stride,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->data,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->stride,
                      GL_FLOAT,
-                     VB->ObjPtr->size,
+                     VB->AttribPtr[_TNL_ATTRIB_POS]->size,
                      0,
                      VB->Count );
 
@@ -249,10 +246,6 @@ static GLboolean run_lighting( GLcontext *ctx,
     */
    store->light_func_tab[idx]( ctx, VB, stage, input );
 
-   VB->AttribPtr[_TNL_ATTRIB_COLOR0] = VB->ColorPtr[0];
-   VB->AttribPtr[_TNL_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
-   VB->AttribPtr[_TNL_ATTRIB_COLOR_INDEX] = VB->IndexPtr[0];
-
    return GL_TRUE;
 }
 
@@ -264,10 +257,7 @@ static void validate_lighting( GLcontext *ctx,
 {
    light_func *tab;
 
-   if (ctx->ShaderObjects._VertexShaderPresent)
-      return;
-
-   if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
+   if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
       return;
 
    if (ctx->Visual.rgbMode) {