Esempio n. 1
0
/* Material
 */
void GLAPIENTRY _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
{
   GET_CURRENT_CONTEXT(ctx);
   GLint i, nr;
   struct gl_material *mat = &ctx->Light.Material;
   GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0,
                                            "_mesa_noop_Materialfv" );

   if (ctx->Light.ColorMaterialEnabled)
      bitmask &= ~ctx->Light.ColorMaterialBitmask;

   if (bitmask == 0)
      return;

   switch (pname) {
   case GL_SHININESS: nr = 1; break;
   case GL_COLOR_INDEXES: nr = 3; break;
   default: nr = 4 ; break;
   }

   for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
      if (bitmask & (1<<i))
	 COPY_SZ_4V( mat->Attrib[i], nr, params ); 

   _mesa_update_material( ctx, bitmask );
}
Esempio n. 2
0
/**
 * Copy the last specified normal, color, texcoord, edge flag, etc
 * from the immediate struct into the ctx->Current attribute group.
 */
void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM,
			   GLuint flag, GLuint count )
{
   if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
      _tnl_print_vert_flags("copy to current", flag);

   /* XXX should be able to replace these conditions with a loop over
    * the 16 vertex attributes.
    */
   if (flag & VERT_BIT_NORMAL)
      COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_NORMAL],
                IM->Attrib[VERT_ATTRIB_NORMAL][count]);

   if (flag & VERT_BIT_COLOR0) {
      COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR0],
               IM->Attrib[VERT_ATTRIB_COLOR0][count]);
      if (ctx->Light.ColorMaterialEnabled) {
	 _mesa_update_color_material( ctx,
                                   ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
 	 TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
      }
   }

   if (flag & VERT_BIT_COLOR1)
      COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR1],
               IM->Attrib[VERT_ATTRIB_COLOR1][count]);

   if (flag & VERT_BIT_FOG)
      ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = IM->Attrib[VERT_ATTRIB_FOG][count][0];

   if (flag & VERT_BIT_SIX)
      COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_SIX], IM->Attrib[VERT_ATTRIB_SIX][count]);

   if (flag & VERT_BIT_SEVEN)
      COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_SEVEN], IM->Attrib[VERT_ATTRIB_SEVEN][count]);

   if (flag & VERT_BITS_TEX_ANY) {
      GLuint i;
      for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
	 if (flag & VERT_BIT_TEX(i)) {
	    COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i],
                      IM->Attrib[VERT_ATTRIB_TEX0 + i][count]);
	 }
      }
   }

   if (flag & VERT_BIT_INDEX)
      ctx->Current.Index = IM->Index[count];

   if (flag & VERT_BIT_EDGEFLAG)
      ctx->Current.EdgeFlag = IM->EdgeFlag[count];

   if (flag & VERT_BIT_MATERIAL) {
      _mesa_update_material( ctx,
			  IM->Material[IM->LastMaterial],
			  IM->MaterialOrMask );

      TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
   }
}
Esempio n. 3
0
/**
 * Prepare things prior to running the lighting stage.
 * Return number of material attributes which will track vertex color.
 */
static GLuint
prepare_materials(GLcontext *ctx,
                  struct vertex_buffer *VB, struct light_stage_data *store)
{
   GLuint i;
   
   store->mat_count = 0;
   store->mat_bitmask = 0;

   /* Examine the ColorMaterialBitmask to determine which materials
    * track vertex color.  Override the material attribute's pointer
    * with the color pointer for each one.
    */
   if (ctx->Light.ColorMaterialEnabled) {
      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];
   }

   /* Now, for each material attribute that's tracking vertex color, save
    * some values (ptr, stride, size, current) that we'll need in
    * update_materials(), above, that'll actually copy the vertex color to
    * the material attribute(s).
    */
   for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ; i < _TNL_ATTRIB_INDEX ; i++) {
      if (VB->AttribPtr[i]->stride) {
	 const GLuint j = store->mat_count++;
	 const GLuint attr = i - _TNL_ATTRIB_MAT_FRONT_AMBIENT;
	 store->mat[j].ptr    = VB->AttribPtr[i]->start;
	 store->mat[j].stride = VB->AttribPtr[i]->stride;
	 store->mat[j].size   = VB->AttribPtr[i]->size;
	 store->mat[j].current = ctx->Light.Material.Attrib[attr];
	 store->mat_bitmask |= (1<<attr);
      }
   }

   /* FIXME: Is this already done?
    */
   _mesa_update_material( ctx, ~0 );
   _mesa_validate_all_lighting_tables( ctx );

   return store->mat_count;
}
Esempio n. 4
0
/**
 * In the case of colormaterial, the effected material attributes
 * should already have been bound to point to the incoming color data,
 * prior to running the pipeline.
 * This function copies the vertex's color to the material attributes
 * which are tracking glColor.
 * It's called per-vertex in the lighting loop.
 */
static void
update_materials(GLcontext *ctx, struct light_stage_data *store)
{
   GLuint i;

   for (i = 0 ; i < store->mat_count ; i++) {
      /* update the material */
      COPY_CLEAN_4V(store->mat[i].current, store->mat[i].size, store->mat[i].ptr);
      /* increment src vertex color pointer */
      STRIDE_F(store->mat[i].ptr, store->mat[i].stride);
   }
      
   /* recompute derived light/material values */
   _mesa_update_material( ctx, store->mat_bitmask );
   /* XXX we should only call this if we're tracking/changing the specular
    * exponent.
    */
   _mesa_validate_all_lighting_tables( ctx );
}