-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
*/
-#if (IDX & LIGHT_TWOSIDE)
+#if IDX & LIGHT_TWOSIDE
# define NR_SIDES 2
#else
# define NR_SIDES 1
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
- GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data;
+#if IDX & LIGHT_TWOSIDE
+ GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].data;
+#endif
const GLuint nr = VB->Count;
VB->SecondaryColorPtr[0] = &store->LitSecondary[0];
sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- if (IDX & LIGHT_TWOSIDE) {
- VB->ColorPtr[1] = &store->LitColor[1];
- VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
- }
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+ VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
/* Side-effects done, can we finish now?
*/
GLfloat sum[2][3], spec[2][3];
struct gl_light *light;
- if ( IDX & LIGHT_MATERIAL ) {
- update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- if (IDX & LIGHT_TWOSIDE)
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
- }
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+#endif
COPY_3V(sum[0], base[0]);
ZERO_3V(spec[0]);
- if (IDX & LIGHT_TWOSIDE) {
- COPY_3V(sum[1], base[1]);
- ZERO_3V(spec[1]);
- }
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], base[1]);
+ ZERO_3V(spec[1]);
+#endif
/* Add contribution from each enabled light source */
foreach (light, &ctx->Light.EnabledList) {
/* Which side gets the diffuse & specular terms? */
if (n_dot_VP < 0.0F) {
ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
- if (!(IDX & LIGHT_TWOSIDE)) {
- continue;
- }
+#if IDX & LIGHT_TWOSIDE
side = 1;
correction = -1;
n_dot_VP = -n_dot_VP;
+#else
+ continue;
+#endif
}
else {
- if (IDX & LIGHT_TWOSIDE) {
- ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
- }
+#if IDX & LIGHT_TWOSIDE
+ ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
+#endif
side = 0;
correction = 1;
}
COPY_3V( Fspec[j], spec[0] );
Fcolor[j][3] = sumA[0];
- if (IDX & LIGHT_TWOSIDE) {
- COPY_3V( Bcolor[j], sum[1] );
- COPY_3V( Bspec[j], spec[1] );
- Bcolor[j][3] = sumA[1];
- }
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V( Bcolor[j], sum[1] );
+ COPY_3V( Bspec[j], spec[1] );
+ Bcolor[j][3] = sumA[1];
+#endif
}
}
VB->ColorPtr[0] = &store->LitColor[0];
sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- if (IDX & LIGHT_TWOSIDE) {
- VB->ColorPtr[1] = &store->LitColor[1];
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
- }
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
if (stage->changed_inputs == 0)
return;
GLfloat sum[2][3];
struct gl_light *light;
- if ( IDX & LIGHT_MATERIAL ) {
- update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- if (IDX & LIGHT_TWOSIDE)
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
- }
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+#endif
COPY_3V(sum[0], base[0]);
- if ( IDX & LIGHT_TWOSIDE )
- COPY_3V(sum[1], base[1]);
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], base[1]);
+#endif
/* Add contribution from each enabled light source */
foreach (light, &ctx->Light.EnabledList) {
/* which side are we lighting? */
if (n_dot_VP < 0.0F) {
ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
-
- if (!(IDX & LIGHT_TWOSIDE))
- continue;
-
+#if IDX & LIGHT_TWOSIDE
side = 1;
correction = -1;
n_dot_VP = -n_dot_VP;
+#else
+ continue;
+#endif
}
else {
- if (IDX & LIGHT_TWOSIDE) {
- ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
- }
+#if IDX & LIGHT_TWOSIDE
+ ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
+#endif
side = 0;
correction = 1;
}
COPY_3V( Fcolor[j], sum[0] );
Fcolor[j][3] = sumA[0];
- if (IDX & LIGHT_TWOSIDE) {
- COPY_3V( Bcolor[j], sum[1] );
- Bcolor[j][3] = sumA[1];
- }
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V( Bcolor[j], sum[1] );
+ Bcolor[j][3] = sumA[1];
+#endif
}
}
const GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
+#endif
const struct gl_light *light = ctx->Light.EnabledList.next;
GLuint j = 0;
- GLfloat base[2][3];
+ GLfloat base[2][4];
const GLuint nr = VB->Count;
#ifdef TRACE
(void) nstride;
VB->ColorPtr[0] = &store->LitColor[0];
- if (IDX & LIGHT_TWOSIDE)
- VB->ColorPtr[1] = &store->LitColor[1];
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+#endif
if (stage->changed_inputs == 0)
return;
GLfloat n_dot_VP;
- if ( IDX & LIGHT_MATERIAL )
- update_materials( ctx, store );
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+#endif
/* No attenuation, so incoporate _MatAmbient into base color.
*/
- if ( j == 0 || (IDX & LIGHT_MATERIAL) ) {
+#if !(IDX & LIGHT_MATERIAL)
+ if ( j == 0 )
+#endif
+ {
COPY_3V(base[0], light->_MatAmbient[0]);
ACC_3V(base[0], ctx->Light._BaseColor[0] );
base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- if (IDX & LIGHT_TWOSIDE) {
- COPY_3V(base[1], light->_MatAmbient[1]);
- ACC_3V(base[1], ctx->Light._BaseColor[1]);
- base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
- }
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(base[1], light->_MatAmbient[1]);
+ ACC_3V(base[1], ctx->Light._BaseColor[1]);
+ base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
}
n_dot_VP = DOT3(normal, light->_VP_inf_norm);
if (n_dot_VP < 0.0F) {
- if (IDX & LIGHT_TWOSIDE) {
- GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
- GLfloat sum[3];
- COPY_3V(sum, base[1]);
- ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
- if (n_dot_h > 0.0F) {
- GLfloat spec;
- GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
- ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
- }
- COPY_3V(Bcolor[j], sum );
- Bcolor[j][3] = base[1][3];
- }
+#if IDX & LIGHT_TWOSIDE
+ GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
+ GLfloat sum[3];
+ COPY_3V(sum, base[1]);
+ ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
+ if (n_dot_h > 0.0F) {
+ GLfloat spec;
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
+ }
+ COPY_3V(Bcolor[j], sum );
+ Bcolor[j][3] = base[1][3];
+#endif
COPY_4FV(Fcolor[j], base[0]);
}
else {
}
COPY_3V(Fcolor[j], sum );
Fcolor[j][3] = base[0][3];
- if (IDX & LIGHT_TWOSIDE) COPY_4FV(Bcolor[j], base[1]);
+#if IDX & LIGHT_TWOSIDE
+ COPY_4FV(Bcolor[j], base[1]);
+#endif
}
}
}
const GLuint nstride = VB->NormalPtr->stride;
const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
+#endif
GLuint j = 0;
const GLuint nr = VB->Count;
const struct gl_light *light;
sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
VB->ColorPtr[0] = &store->LitColor[0];
- if (IDX & LIGHT_TWOSIDE)
- VB->ColorPtr[1] = &store->LitColor[1];
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+#endif
if (stage->changed_inputs == 0)
return;
GLfloat sum[2][3];
- if ( IDX & LIGHT_MATERIAL ) {
- update_materials( ctx, store );
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- if (IDX & LIGHT_TWOSIDE)
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
- }
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+#endif
COPY_3V(sum[0], ctx->Light._BaseColor[0]);
- if (IDX & LIGHT_TWOSIDE)
- COPY_3V(sum[1], ctx->Light._BaseColor[1]);
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], ctx->Light._BaseColor[1]);
+#endif
foreach (light, &ctx->Light.EnabledList) {
GLfloat n_dot_h, n_dot_VP, spec;
ACC_3V(sum[0], light->_MatAmbient[0]);
- if (IDX & LIGHT_TWOSIDE)
- ACC_3V(sum[1], light->_MatAmbient[1]);
+#if IDX & LIGHT_TWOSIDE
+ ACC_3V(sum[1], light->_MatAmbient[1]);
+#endif
n_dot_VP = DOT3(normal, light->_VP_inf_norm);
ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]);
}
}
- else if (IDX & LIGHT_TWOSIDE) {
+#if IDX & LIGHT_TWOSIDE
+ else {
ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]);
n_dot_h = -DOT3(normal, light->_h_inf_norm);
if (n_dot_h > 0.0F) {
ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]);
}
}
+#endif
}
COPY_3V( Fcolor[j], sum[0] );
Fcolor[j][3] = sumA[0];
- if (IDX & LIGHT_TWOSIDE) {
- COPY_3V( Bcolor[j], sum[1] );
- Bcolor[j][3] = sumA[1];
- }
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V( Bcolor[j], sum[1] );
+ Bcolor[j][3] = sumA[1];
+#endif
}
}
(void) vstride;
VB->IndexPtr[0] = &store->LitIndex[0];
- if (IDX & LIGHT_TWOSIDE)
- VB->IndexPtr[1] = &store->LitIndex[1];
+#if IDX & LIGHT_TWOSIDE
+ VB->IndexPtr[1] = &store->LitIndex[1];
+#endif
if (stage->changed_inputs == 0)
return;
indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data;
- if (IDX & LIGHT_TWOSIDE)
- indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
+#if IDX & LIGHT_TWOSIDE
+ indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
+#endif
/* loop over vertices */
for (j=0; j<nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal, nstride)) {
GLuint side = 0;
struct gl_light *light;
- if ( IDX & LIGHT_MATERIAL )
- update_materials( ctx, store );
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+#endif
diffuse[0] = specular[0] = 0.0F;
- if ( IDX & LIGHT_TWOSIDE ) {
+#if IDX & LIGHT_TWOSIDE
diffuse[1] = specular[1] = 0.0F;
- }
+#endif
/* Accumulate diffuse and specular from each light source */
foreach (light, &ctx->Light.EnabledList) {
/* which side are we lighting? */
if (n_dot_VP < 0.0F) {
- if (!(IDX & LIGHT_TWOSIDE))
- continue;
+#if IDX & LIGHT_TWOSIDE
side = 1;
correction = -1;
n_dot_VP = -n_dot_VP;
+#else
+ continue;
+#endif
}
/* accumulate diffuse term */