summaryrefslogtreecommitdiff
path: root/src/mesa/tnl/t_vb_lighttmp.h
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-12-04 03:19:46 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-12-04 03:19:46 +0000
commitb305028464f02947c0cce0476af0e35f4ed1fafa (patch)
tree6623fb86dea2eb572743c161055e37a1d43c995d /src/mesa/tnl/t_vb_lighttmp.h
parent03e29a5f77c13b7b888bd8443cb2752850e47d6a (diff)
Port over changes from XFree86/Mesa 5.0.2, mostly to silence compiler warnings.
Diffstat (limited to 'src/mesa/tnl/t_vb_lighttmp.h')
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h195
1 files changed, 108 insertions, 87 deletions
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index 167325eae8..7af1a4bfab 100644
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ b/src/mesa/tnl/t_vb_lighttmp.h
@@ -1,9 +1,8 @@
-
/*
* 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"),
@@ -61,9 +60,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
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;
@@ -78,11 +79,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
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?
*/
@@ -93,20 +94,21 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
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) {
@@ -167,17 +169,18 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
/* 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;
}
@@ -224,11 +227,11 @@ static void TAG(light_rgba_spec)( GLcontext *ctx,
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
}
}
@@ -268,10 +271,10 @@ static void TAG(light_rgba)( GLcontext *ctx,
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;
@@ -283,8 +286,9 @@ static void TAG(light_rgba)( GLcontext *ctx,
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_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
}
COPY_3V(sum[0], base[0]);
@@ -353,18 +357,18 @@ static void TAG(light_rgba)( GLcontext *ctx,
/* 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;
}
@@ -413,10 +417,10 @@ static void TAG(light_rgba)( GLcontext *ctx,
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
}
}
@@ -435,7 +439,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
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];
@@ -450,8 +456,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
(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;
@@ -470,29 +477,29 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
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 {
@@ -508,7 +515,9 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
}
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
}
}
}
@@ -526,7 +535,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
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;
@@ -543,8 +554,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
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;
@@ -557,21 +569,24 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
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_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#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);
@@ -584,7 +599,8 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
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) {
@@ -593,15 +609,16 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
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
}
}
@@ -640,15 +657,17 @@ static void TAG(light_ci)( GLcontext *ctx,
(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)) {
@@ -716,11 +735,13 @@ static void TAG(light_ci)( GLcontext *ctx,
/* 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 */