Symbol names are prepended with an underscore on CYGWIN as well.
[mesa.git] / src / mesa / tnl / t_vb_lighttmp.h
index 167325eae83d6782289c3942555a82912cea1b9f..2eaf61ff4d093acb035168104e165391d8b688dd 100644 (file)
@@ -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"),
@@ -29,7 +28,7 @@
  */
 
 
-#if (IDX & LIGHT_TWOSIDE)
+#if IDX & LIGHT_TWOSIDE
 #  define NR_SIDES 2
 #else
 #  define NR_SIDES 1
@@ -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;
@@ -280,17 +283,19 @@ static void TAG(light_rgba)( GLcontext *ctx,
       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) {
@@ -353,18 +358,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 +418,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,10 +440,12 @@ 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];
+   GLfloat base[2][4];
    const GLuint nr = VB->Count;
 
 #ifdef TRACE
@@ -450,8 +457,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;
@@ -460,39 +468,43 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx,
 
       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 {
@@ -508,7 +520,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 +540,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 +559,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;
@@ -553,25 +570,28 @@ static void TAG(light_fast_rgba)( GLcontext *ctx,
 
       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);
 
@@ -584,7 +604,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 +614,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 +662,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)) {
@@ -656,14 +680,15 @@ static void TAG(light_ci)( GLcontext *ctx,
       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) {
@@ -716,11 +741,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 */