Changes for multitexture > 3, code clean-ups.
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 20 Oct 2000 19:54:49 +0000 (19:54 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 20 Oct 2000 19:54:49 +0000 (19:54 +0000)
Added GLboolean ctx->Texture.MultiTextureEnabled to determine when
multitexture is enabled.  Eventually ctx->Texture.ReallyEnabled may
become a boolean.

src/mesa/main/context.c
src/mesa/main/lines.c
src/mesa/main/points.c
src/mesa/main/state.c
src/mesa/main/varray.c

index 34180a7..3f4bcec 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.92 2000/10/09 22:42:40 brianp Exp $ */
+/* $Id: context.c,v 1.93 2000/10/20 19:54:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -882,8 +882,14 @@ init_attrib_groups( GLcontext *ctx )
    ASSIGN_3V( ctx->Current.Normal, 0.0, 0.0, 1.0 );
    ctx->Current.Primitive = (GLenum) (GL_POLYGON + 1);
 
-   ctx->Current.Flag = (VERT_NORM|VERT_INDEX|VERT_RGBA|VERT_EDGE|
-                        VERT_TEX0_1|VERT_TEX1_1|VERT_MATERIAL);
+   ctx->Current.Flag = (VERT_NORM |
+                        VERT_INDEX | 
+                        VERT_RGBA |
+                        VERT_EDGE |
+                        VERT_TEX0_1 |
+                        VERT_TEX1_1 |
+                        VERT_TEX2_1 | /* XXX fix for MAX_TEXTURE_UNITS > 3 */
+                        VERT_MATERIAL);
 
    init_fallback_arrays( ctx );
 
index 7330ea5..41d3262 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lines.c,v 1.15 2000/09/30 18:42:29 brianp Exp $ */
+/* $Id: lines.c,v 1.16 2000/10/20 19:54:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1086,7 +1086,7 @@ void gl_set_line_function( GLcontext *ctx )
          /* antialiased lines */
          if (rgbmode) {
             if (ctx->Texture.ReallyEnabled) {
-               if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D
+               if (ctx->Texture.MultiTextureEnabled
                   || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
                   /* Multitextured! */
                   ctx->Driver.LineFunc = aa_multitex_rgba_line;
@@ -1101,7 +1101,7 @@ void gl_set_line_function( GLcontext *ctx )
          }
       }
       else if (ctx->Texture.ReallyEnabled) {
-         if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D
+         if (ctx->Texture.MultiTextureEnabled
              || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
             /* multi-texture and/or separate specular color */
             if (ctx->Light.ShadeModel==GL_SMOOTH)
index 75f1244..0ab383b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: points.c,v 1.14 2000/09/29 16:58:44 brianp Exp $ */
+/* $Id: points.c,v 1.15 2000/10/20 19:54:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -590,7 +590,7 @@ antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
                         /* coverage is in [0,256] */
                         alpha = (alpha * coverage) >> 8;
                      }
-                     if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
+                     if (ctx->Texture.MultiTextureEnabled) {
                         PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, red, green, blue, 
                                                 alpha, texcoord );
                      }
@@ -974,7 +974,7 @@ dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
 
          for (iy = y0; iy <= y1; iy++) {
             for (ix = x0; ix <= x1; ix++) {
-               if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
+               if (ctx->Texture.MultiTextureEnabled) {
                   PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z,
                                            red, green, blue, alpha,
                                            texcoord );
@@ -1092,7 +1092,7 @@ dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last )
                         alpha = (alpha * coverage) >> 8;
                      }
                      alpha = (GLint) (alpha * alphaf);
-                     if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
+                     if (ctx->Texture.MultiTextureEnabled) {
                         PB_WRITE_MULTITEX_PIXEL( PB, x, y, z,
                                                  red, green, blue, alpha,
                                                  texcoord );
@@ -1230,7 +1230,7 @@ void gl_set_point_function( GLcontext *ctx )
             ctx->Driver.PointsFunc = antialiased_rgba_points;
          }
          else if (ctx->Texture.ReallyEnabled) {
-            if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D ||
+            if (ctx->Texture.MultiTextureEnabled ||
                 ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
               ctx->Driver.PointsFunc = multitextured_rgba_points;
             }
index eeb7363..bc0e014 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.31 2000/10/18 15:02:59 brianp Exp $ */
+/* $Id: state.c,v 1.32 2000/10/20 19:54:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -853,6 +853,7 @@ void gl_update_state( GLcontext *ctx )
    }
 
    if (ctx->NewState & (NEW_TEXTURING | NEW_TEXTURE_ENABLE)) {
+      ctx->Texture.MultiTextureEnabled = GL_FALSE;
       ctx->Texture.NeedNormals = GL_FALSE;
       gl_update_dirty_texobjs(ctx);
       ctx->Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2);
@@ -877,6 +878,10 @@ void gl_update_state( GLcontext *ctx )
                  ctx->Texture.NeedEyeCoords = GL_TRUE;
               }
            }
+
+            if (i > 0 && ctx->Texture.Unit[i].ReallyEnabled) {
+               ctx->Texture.MultiTextureEnabled = GL_TRUE;
+            }
         }
       }
 
index 62e5019..78cff94 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: varray.c,v 1.24 2000/10/18 15:02:59 brianp Exp $ */
+/* $Id: varray.c,v 1.25 2000/10/20 19:54:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -490,11 +490,18 @@ void gl_exec_array_elements( GLcontext *ctx, struct immediate *IM,
 
 #if MAX_TEXTURE_UNITS > 2
    if (translate & VERT_TEX2_ANY)
-      (ctx->Array.TexCoordEltFunc[1])( IM->TexCoord[2], 
+      (ctx->Array.TexCoordEltFunc[2])( IM->TexCoord[2], 
                                       &ctx->Array.TexCoord[2], 
                                       flags, elts, (VERT_ELT|VERT_TEX2_ANY),
                                       start, count);
 #endif
+#if MAX_TEXTURE_UNITS > 3
+   if (translate & VERT_TEX3_ANY)
+      (ctx->Array.TexCoordEltFunc[3])( IM->TexCoord[3], 
+                                      &ctx->Array.TexCoord[3], 
+                                      flags, elts, (VERT_ELT|VERT_TEX3_ANY),
+                                      start, count);
+#endif
 
    for (i = start ; i < count ; i++) 
       if (flags[i] & VERT_ELT) 
@@ -711,6 +718,13 @@ _mesa_DrawArrays(GLenum mode, GLint start, GLsizei count)
                                        TexCoord[2], start, n );
         }
 #endif
+#if MAX_TEXTURE_UNITS > 3
+        if (required & VERT_TEX3_ANY) {
+           IM->v.TexCoord[3].size = TexCoord[3]->Size;
+           ctx->Array.TexCoordFunc[3]( IM->TexCoord[3] + VB_START, 
+                                       TexCoord[3], start, n );
+        }
+#endif
 
         VB->ObjPtr = &IM->v.Obj;
         VB->NormalPtr = &IM->v.Normal;