-/* $Id: light.c,v 1.43 2001/04/28 08:39:17 keithw Exp $ */
+/* $Id: light.c,v 1.49 2002/02/13 00:53:19 keithw Exp $ */
/*
* Mesa 3-D graphics library
case GL_POSITION: {
GLfloat tmp[4];
/* transform position by ModelView matrix */
- TRANSFORM_POINT( tmp, ctx->ModelView.m, params );
+ TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->m, params );
if (TEST_EQ_4V(l->EyePosition, tmp))
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
case GL_SPOT_DIRECTION: {
GLfloat tmp[4];
/* transform direction by inverse modelview */
- if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
- _math_matrix_analyse( &ctx->ModelView );
+ if (ctx->ModelviewMatrixStack.Top->flags & MAT_DIRTY_INVERSE) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
}
- TRANSFORM_NORMAL( tmp, params, ctx->ModelView.inv );
+ TRANSFORM_NORMAL( tmp, params, ctx->ModelviewMatrixStack.Top->inv );
if (TEST_EQ_3V(l->EyeDirection, tmp))
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
l->SpotCutoff = params[0];
- l->_CosCutoff = cos(params[0]*DEG2RAD);
+ l->_CosCutoff = (GLfloat) cos(params[0]*DEG2RAD);
if (l->_CosCutoff < 0)
l->_CosCutoff = 0;
if (l->SpotCutoff != 180.0F)
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.Model.TwoSide = newbool;
+
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
+ else
+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
break;
case GL_LIGHT_MODEL_COLOR_CONTROL:
if (params[0] == (GLfloat) GL_SINGLE_COLOR)
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse );
}
- UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]);
}
if (bitmask & BACK_DIFFUSE_BIT) {
struct gl_material *mat = &ctx->Light.Material[1];
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse );
}
- UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]);
}
/* update material specular values */
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse );
}
- UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[0], mat->Diffuse[3]);
}
if (bitmask & BACK_DIFFUSE_BIT) {
foreach (light, list) {
SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse );
}
- UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[1], mat->Diffuse[3]);
}
/* update light->_MatSpecular = light's specular * material's specular */
if (ctx->Light.ColorMaterialEnabled) {
FLUSH_CURRENT( ctx, 0 );
- _mesa_update_color_material( ctx, ctx->Current.Color );
+ _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
}
+
+ if (ctx->Driver.ColorMaterial)
+ (*ctx->Driver.ColorMaterial)( ctx, face, mode );
}
clamp = 1;
}
}
- l->_SpotExpTable[i][0] = tmp;
+ l->_SpotExpTable[i][0] = (GLfloat) tmp;
}
for (i = 0; i < EXP_TABLE_SIZE - 1; i++) {
l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] -
x = 0.005;
t = pow(x, shininess);
if (t > 1e-20)
- m[j] = t;
+ m[j] = (GLfloat) t;
else
m[j] = 0.0;
}
_mesa_update_lighting( GLcontext *ctx )
{
struct gl_light *light;
- ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
ctx->_NeedEyeCoords &= ~NEED_EYE_LIGHT;
ctx->_NeedNormals &= ~NEED_NORMALS_LIGHT;
ctx->Light._Flags = 0;
ctx->_NeedNormals |= NEED_NORMALS_LIGHT;
- if (ctx->Light.Model.TwoSide)
- ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-
foreach(light, &ctx->Light.EnabledList) {
ctx->Light._Flags |= light->_Flags;
}
ACC_SCALE_3V(ctx->Light._BaseColor[side],
ctx->Light.Model.Ambient,
mat->Ambient);
-
- UNCLAMPED_FLOAT_TO_CHAN(ctx->Light._BaseAlpha[side],
- ctx->Light.Material[side].Diffuse[3] );
}
foreach (light, &ctx->Light.EnabledList) {
}
}
else {
- static const GLfloat ci[3] = { .30, .59, .11 };
+ static const GLfloat ci[3] = { .30F, .59F, .11F };
foreach(light, &ctx->Light.EnabledList) {
light->_dli = DOT3(ci, light->Diffuse);
light->_sli = DOT3(ci, light->Specular);
COPY_3V( ctx->_EyeZDir, eye_z );
}
else {
- TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelView.m );
+ TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m );
}
foreach (light, &ctx->Light.EnabledList) {
COPY_4FV( light->_Position, light->EyePosition );
}
else {
- TRANSFORM_POINT( light->_Position, ctx->ModelView.inv,
+ TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv,
light->EyePosition );
}
else {
TRANSFORM_NORMAL( light->_NormDirection,
light->EyeDirection,
- ctx->ModelView.m);
+ ctx->ModelviewMatrixStack.Top->m);
}
NORMALIZE_3FV( light->_NormDirection );
double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
int k = (int) x;
light->_VP_inf_spot_attenuation =
- (light->_SpotExpTable[k][0] +
+ (GLfloat) (light->_SpotExpTable[k][0] +
(x-k)*light->_SpotExpTable[k][1]);
}
else {