meta: Don't ask for floating point textures if not ARB_texture_float.
[mesa.git] / src / mesa / tnl / t_vb_light.c
index f47f99397c9ad29bf59664884f66325f1d25d879..3acedf6e577da2cf644166e8ac538439143107d3 100644 (file)
@@ -41,7 +41,7 @@
 #define LIGHT_MATERIAL      0x2
 #define MAX_LIGHT_FUNC      0x4
 
-typedef void (*light_func)( GLcontext *ctx,
+typedef void (*light_func)( struct gl_context *ctx,
                            struct vertex_buffer *VB,
                            struct tnl_pipeline_stage *stage,
                            GLvector4f *input );
@@ -64,7 +64,6 @@ struct light_stage_data {
    GLvector4f Input;
    GLvector4f LitColor[2];
    GLvector4f LitSecondary[2];
-   GLvector4f LitIndex[2];
    light_func *light_func_tab;
 
    struct material_cursor mat[MAT_ATTRIB_MAX];
@@ -86,7 +85,7 @@ struct light_stage_data {
  * It's called per-vertex in the lighting loop.
  */
 static void
-update_materials(GLcontext *ctx, struct light_stage_data *store)
+update_materials(struct gl_context *ctx, struct light_stage_data *store)
 {
    GLuint i;
 
@@ -111,7 +110,7 @@ update_materials(GLcontext *ctx, struct light_stage_data *store)
  * Return number of material attributes which will track vertex color.
  */
 static GLuint
-prepare_materials(GLcontext *ctx,
+prepare_materials(struct gl_context *ctx,
                   struct vertex_buffer *VB, struct light_stage_data *store)
 {
    GLuint i;
@@ -127,7 +126,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
@@ -161,7 +160,6 @@ static light_func _tnl_light_tab[MAX_LIGHT_FUNC];
 static light_func _tnl_light_fast_tab[MAX_LIGHT_FUNC];
 static light_func _tnl_light_fast_single_tab[MAX_LIGHT_FUNC];
 static light_func _tnl_light_spec_tab[MAX_LIGHT_FUNC];
-static light_func _tnl_light_ci_tab[MAX_LIGHT_FUNC];
 
 #define TAG(x)           x
 #define IDX              (0)
@@ -194,13 +192,13 @@ static void init_lighting_tables( void )
 }
 
 
-static GLboolean run_lighting( GLcontext *ctx, 
+static GLboolean run_lighting( struct gl_context *ctx, 
                               struct tnl_pipeline_stage *stage )
 {
    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->Light.Enabled || ctx->VertexProgram._Current)
@@ -208,13 +206,13 @@ static GLboolean run_lighting( GLcontext *ctx,
 
    /* 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 );
 
@@ -246,17 +244,13 @@ 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;
 }
 
 
 /* Called in place of do_lighting when the light table may have changed.
  */
-static void validate_lighting( GLcontext *ctx,
+static void validate_lighting( struct gl_context *ctx,
                                        struct tnl_pipeline_stage *stage )
 {
    light_func *tab;
@@ -264,22 +258,18 @@ static void validate_lighting( GLcontext *ctx,
    if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
       return;
 
-   if (ctx->Visual.rgbMode) {
-      if (ctx->Light._NeedVertices) {
-        if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
-           tab = _tnl_light_spec_tab;
-        else
-           tab = _tnl_light_tab;
-      }
-      else {
-        if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
-           tab = _tnl_light_fast_single_tab;
-        else
-           tab = _tnl_light_fast_tab;
-      }
+   if (ctx->Light._NeedVertices) {
+      if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+        tab = _tnl_light_spec_tab;
+      else
+        tab = _tnl_light_tab;
+   }
+   else {
+      if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
+        tab = _tnl_light_fast_single_tab;
+      else
+        tab = _tnl_light_fast_tab;
    }
-   else
-      tab = _tnl_light_ci_tab;
 
 
    LIGHT_STAGE_DATA(stage)->light_func_tab = tab;
@@ -294,7 +284,7 @@ static void validate_lighting( GLcontext *ctx,
 /* Called the first time stage->run is called.  In effect, don't
  * allocate data until the first time the stage is run.
  */
-static GLboolean init_lighting( GLcontext *ctx,
+static GLboolean init_lighting( struct gl_context *ctx,
                                struct tnl_pipeline_stage *stage )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -315,19 +305,12 @@ static GLboolean init_lighting( GLcontext *ctx,
    _mesa_vector4f_alloc( &store->LitColor[1], 0, size, 32 );
    _mesa_vector4f_alloc( &store->LitSecondary[0], 0, size, 32 );
    _mesa_vector4f_alloc( &store->LitSecondary[1], 0, size, 32 );
-   _mesa_vector4f_alloc( &store->LitIndex[0], 0, size, 32 );
-   _mesa_vector4f_alloc( &store->LitIndex[1], 0, size, 32 );
 
    store->LitColor[0].size = 4;
    store->LitColor[1].size = 4;
    store->LitSecondary[0].size = 3;
    store->LitSecondary[1].size = 3;
 
-   store->LitIndex[0].size = 1;
-   store->LitIndex[0].stride = sizeof(GLfloat);
-   store->LitIndex[1].size = 1;
-   store->LitIndex[1].stride = sizeof(GLfloat);
-
    return GL_TRUE;
 }
 
@@ -344,8 +327,6 @@ static void dtr( struct tnl_pipeline_stage *stage )
       _mesa_vector4f_free( &store->LitColor[1] );
       _mesa_vector4f_free( &store->LitSecondary[0] );
       _mesa_vector4f_free( &store->LitSecondary[1] );
-      _mesa_vector4f_free( &store->LitIndex[0] );
-      _mesa_vector4f_free( &store->LitIndex[1] );
       FREE( store );
       stage->privatePtr = NULL;
    }