/* 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 ); }
static void _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); struct immediate *IM = TNL_CURRENT_IM(ctx); GLuint count = IM->Count; struct gl_material *mat; GLuint bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, "Materialfv"); if (bitmask == 0) return; if (MESA_VERBOSE & VERBOSE_API) fprintf(stderr, "_tnl_Materialfv\n"); if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ { _tnl_flush_immediate( IM ); IM = TNL_CURRENT_IM(ctx); count = IM->Count; } if (!(IM->Flag[count] & VERT_MATERIAL)) { if (!IM->Material) { IM->Material = (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial) * IMM_SIZE * 2 ); IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); IM->MaterialMask[IM->LastMaterial] = 0; } else if (IM->MaterialOrMask & ~bitmask) { _mesa_copy_material_pairs( IM->Material[count], IM->Material[IM->LastMaterial], IM->MaterialOrMask & ~bitmask ); } IM->Flag[count] |= VERT_MATERIAL; IM->MaterialMask[count] = 0; IM->MaterialAndMask &= IM->MaterialMask[IM->LastMaterial]; IM->LastMaterial = count; } IM->MaterialOrMask |= bitmask; IM->MaterialMask[count] |= bitmask; mat = IM->Material[count]; if (bitmask & FRONT_AMBIENT_BIT) { COPY_4FV( mat[0].Ambient, params ); } if (bitmask & BACK_AMBIENT_BIT) { COPY_4FV( mat[1].Ambient, params ); } if (bitmask & FRONT_DIFFUSE_BIT) { COPY_4FV( mat[0].Diffuse, params ); } if (bitmask & BACK_DIFFUSE_BIT) { COPY_4FV( mat[1].Diffuse, params ); } if (bitmask & FRONT_SPECULAR_BIT) { COPY_4FV( mat[0].Specular, params ); } if (bitmask & BACK_SPECULAR_BIT) { COPY_4FV( mat[1].Specular, params ); } if (bitmask & FRONT_EMISSION_BIT) { COPY_4FV( mat[0].Emission, params ); } if (bitmask & BACK_EMISSION_BIT) { COPY_4FV( mat[1].Emission, params ); } if (bitmask & FRONT_SHININESS_BIT) { GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F ); mat[0].Shininess = shininess; } if (bitmask & BACK_SHININESS_BIT) { GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F ); mat[1].Shininess = shininess; } if (bitmask & FRONT_INDEXES_BIT) { mat[0].AmbientIndex = params[0]; mat[0].DiffuseIndex = params[1]; mat[0].SpecularIndex = params[2]; } if (bitmask & BACK_INDEXES_BIT) { mat[1].AmbientIndex = params[0]; mat[1].DiffuseIndex = params[1]; mat[1].SpecularIndex = params[2]; } if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ { _tnl_flush_immediate( IM ); } }