gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx demo/irregu4.py libutil/Irregu.hxx


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregu4.py libutil/Irregu.hxx
Date: Thu, 14 Nov 2002 08:30:23 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/11/14 08:30:23

Modified files:
        gfx/demo       : irregu4.py 
        gfx/libutil    : Irregu.hxx 

Log message:
        Interpolate between two texture units if SLICE_1D and SLICE_2D are 
specified

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu4.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/Irregu.hxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu4.py
diff -u gzz/gfx/demo/irregu4.py:1.12 gzz/gfx/demo/irregu4.py:1.13
--- gzz/gfx/demo/irregu4.py:1.12        Thu Nov 14 06:14:41 2002
+++ gzz/gfx/demo/irregu4.py     Thu Nov 14 08:30:23 2002
@@ -246,7 +246,7 @@
         texslicing = self.texslicing
 
         stdcode = """
-            PushAttrib ENABLE_BIT TEXTURE_BIT
+            PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
             BindTexture TEXTURE_2D %s
             TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
             TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
@@ -254,14 +254,60 @@
             TexEnv TEXTURE_ENV TEXTURE_ENV_MODE ADD
             Enable ALPHA_TEST
             AlphaFunc GEQUAL 1.0
-            """  % texINTENSITY.getTexId() 
+            """ % texINTENSITY.getTexId() 
+
+        slice = SLICE_1D + (1 - (self.flags >> 6 & 1)) * SLICE_2D;
+        if slice & SLICE_2D:
+            stdcode += combinercode("""
+            SecondaryColorEXT .5 .5 .5
+            
+            ActiveTexture TEXTURE1
+            BindTexture TEXTURE_2D %s
+            TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
+            TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
+            Enable TEXTURE_2D
+            ActiveTexture TEXTURE0
+            
+            Enable REGISTER_COMBINERS_NV
+            CombinerParameterNV NUM_GENERAL_COMBINERS_NV 2
+
+            CI0 RGB A TEXTURE0 UNSIGNED_IDENTITY_NV RGB
+            CI0 RGB B SECONDARY_COLOR_NV UNSIGNED_INVERT_NV RGB
+            CI0 RGB C TEXTURE1 UNSIGNED_IDENTITY_NV RGB
+            CI0 RGB D SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
+            CO0 RGB DISCARD_NV DISCARD_NV SPARE0_NV NONE NONE FALSE FALSE FALSE
+            
+            CI0 ALPHA A TEXTURE0 UNSIGNED_IDENTITY_NV ALPHA
+            CI0 ALPHA B SECONDARY_COLOR_NV UNSIGNED_INVERT_NV BLUE
+            CI0 ALPHA C TEXTURE1 UNSIGNED_IDENTITY_NV ALPHA
+            CI0 ALPHA D SECONDARY_COLOR_NV UNSIGNED_IDENTITY_NV BLUE
+            CO0 ALPHA DISCARD_NV DISCARD_NV SPARE0_NV NONE NONE FALSE FALSE 
FALSE
+
+            CI1 RGB A SPARE0_NV UNSIGNED_IDENTITY_NV RGB
+            CI1 RGB B ZERO UNSIGNED_INVERT_NV RGB
+            CI1 RGB C PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV RGB
+            CI1 RGB D ZERO UNSIGNED_INVERT_NV RGB
+            CO1 RGB DISCARD_NV DISCARD_NV SPARE0_NV NONE NONE FALSE FALSE FALSE
+            
+            CI1 ALPHA A SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA
+            CI1 ALPHA B ZERO UNSIGNED_INVERT_NV ALPHA
+            CI1 ALPHA C PRIMARY_COLOR_NV UNSIGNED_IDENTITY_NV ALPHA
+            CI1 ALPHA D ZERO UNSIGNED_INVERT_NV ALPHA
+            CO1 ALPHA DISCARD_NV DISCARD_NV SPARE0_NV NONE NONE FALSE FALSE 
FALSE
+            # output rgba <- SPARE0
+            FCI A ZERO UNSIGNED_IDENTITY_NV RGB
+            FCI B ZERO UNSIGNED_IDENTITY_NV RGB
+            FCI C ZERO UNSIGNED_IDENTITY_NV RGB
+            FCI D SPARE0_NV UNSIGNED_IDENTITY_NV RGB
+            FCI G SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA
+            """) % texINTENSITY.getTexId() 
 
         self.outer = GLRen.createIrregularEdge(shape,
             texscale, linewidth, refsize, scale_pow,
             border0, border1, texslicing,
             "0 0 0 1 0 0 0 0", "",
             0, 0,
-            SLICE_1D + Y_COLOR + SHIFTS, stdcode + """
+            slice + Y_COLOR + SHIFTS, stdcode + """
             BlendFunc ZERO ZERO
             Enable BLEND
             """, 1.0)
@@ -276,14 +322,14 @@
             border0, border1, texslicing,
             ("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], "",
             0, 0,
-            SLICE_1D + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, stdcode, 1.0)
+            slice + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, stdcode, 1.0)
 
         if GL.hasExtension("GL_NV_register_combiners") and 0:
             self.outer = GLRen.createIrregularEdge(shape,
                 texscale, linewidth, refsize, scale_pow,
                 border0, border1, texslicing,
                 "1 1 1 1 0 0 0 0", "", 3, 0,
-                Y_SECCOLOR + SLICE_1D + DOTVEC_COLOR + INTERP_DOTVEC,
+                Y_SECCOLOR + slice + DOTVEC_COLOR + INTERP_DOTVEC,
                 outer_code, 1.0)
             
         if (GL.hasExtension("GL_NV_register_combiners") and
@@ -296,7 +342,7 @@
                 texscale, linewidth, refsize, scale_pow,
                 border0, border1, texslicing,
                 "1 1 1 1 0 0 0 0", "", 0, 1,
-                Y_SECCOLOR + SLICE_1D,
+                Y_SECCOLOR + slice,
                 outer_code, 1.0)
 
 
@@ -345,6 +391,7 @@
         print "4: OUTER EDGE", self.flags >> 3 & 1
         print "5: INSIDE", self.flags >> 4 & 1
         print "6: STENCIL", self.flags >> 5 & 1
+        print "7: 2ND TEXCOORDS (inv)", self.flags >> 6 & 1
 
     def key(self, k):
         if 0: pass
Index: gzz/gfx/libutil/Irregu.hxx
diff -u gzz/gfx/libutil/Irregu.hxx:1.11 gzz/gfx/libutil/Irregu.hxx:1.12
--- gzz/gfx/libutil/Irregu.hxx:1.11     Wed Nov 13 15:52:12 2002
+++ gzz/gfx/libutil/Irregu.hxx  Thu Nov 14 08:30:23 2002
@@ -74,7 +74,7 @@
     }
 
     /** Draws an irregular edge
-     * @param coords     the mapping 
+     * @param coords     vertex->screen transformation
      * @param pt         vertices of the edge
      * @param norm       normals at each vertex 
      * @param texscale   vertex to texcoords scaling (divides texcoords)
@@ -88,7 +88,8 @@
      * @param texslicing a border0 and border1 factor for texcoords
      * @param c0         constant vector; currently specifies 
      *                   inner and outer color 4+4 floats
-     * @param c1         second constant vecotr; currently not used
+     * @param c1         second constant vecotr; used for secondary
+     *                   color if c0 is already taken for primary color
      * @param angles     number of precomputed slicing angles in the texture
      * @param multi      the "radius" of texture units (i.e, (1 + 2 * multi)
      *                   units); multi > 0 also enables some hardcoded options
@@ -101,8 +102,8 @@
      *                   (2D texture slice requires full 360 degree span)
      *   INTERP_DOTVEC   interpolate the dotvector using normals at each vertex
      *                   (as opposed to using tangents at each quad)
-     *   SLICE_1D        map 1D texture slice (or 2D if texslicing != 0)
-     *   SLICE_2D        map 2D texture slice (obsolete)
+     *   SLICE_1D        map 1D tex slice (or 2D if texslicing != 0)
+     *   SLICE_2D        map 2D tex slice (use w/ SLICE_1D to get both coords)
      *   SHIFTS          draw each quad 3 or 4 (texslicing != 0) times 
      *                   with linewidth-perturbed coordinates
      *   INSIDE          draw the inside as a polygon 
@@ -120,9 +121,11 @@
        if (pt.size() < 2) return;
 
        void (*colorfv)(const GLfloat *v) = nop;
+       void (*colorfv2)(const GLfloat *v) = nop;
 
        if (flags & Y_COLOR) colorfv = glColor4fv;
-       if (flags & Y_SECCOLOR) colorfv = glSecondaryColor3fvEXT;
+       if (flags & Y_SECCOLOR) 
+           (flags & Y_COLOR ? colorfv2 : colorfv) = glSecondaryColor3fvEXT;
        
 
        ZPt vert[pt.size()][2];
@@ -143,12 +146,14 @@
            glBegin(GL_POLYGON);
            for (unsigned i = 0; i < pt.size(); i++) {
                texCoord(vert[i][0], texscale);
+               if ((flags & SLICE_1D + SLICE_2D) == SLICE_1D + SLICE_2D)
+                   multiTexCoord(GL_TEXTURE1, vert[i][0], texscale);
                coords.vertex(vert[i][0]);
            }
            glEnd();
        }
 
-       if (flags & SLICE_2D) {
+       if ((flags & SLICE_2D) && !(flags & SLICE_1D)) {
            glBegin(GL_QUAD_STRIP);
            for (unsigned i = 0; i < pt.size(); i++) {
 
@@ -161,10 +166,12 @@
                }
                
                colorfv(c0);
+               colorfv2(c1);
                texCoord(vert[i][0], texscale);
                vertex(vert2[i][0]);
 
                colorfv(c0 + 4);
+               colorfv2(c1 + 4);
                texCoord(vert[i][1], texscale);
                vertex(vert2[i][1]);
            }
@@ -215,7 +222,9 @@
                ZVec shift0(0,0,0);
                ZVec shift1(0,0,0);
 
-               int numshifts = flags & SHIFTS ? 3 + (texslicing != 0) : 1;
+               int numshifts = flags & SHIFTS 
+                   ? 3 + (texslicing != 0 || flags & SLICE_2D) 
+                   : 1;
                for (int s = 0; s < numshifts; s++) {
                if (flags & SHIFTS) {
                    switch (s) {
@@ -251,8 +260,10 @@
 
                if (multi > 0) glColor4f(0,0,dy1,dy1);
                colorfv(c0 + 4);
+               colorfv2(c1 + 4);
                texCoord(a1q, texscale * q1);
                u = GL_TEXTURE1;
+               if (flags & SLICE_2D) multiTexCoord(u, vert[i][1], texscale);
                for (int d = 1; d <= multi; d++) {
                    multiTexCoord(u++, a1q + d * q1 * d1, texscale * q1);
                    multiTexCoord(u++, a1q - d * q1 * d1, texscale * q1);
@@ -261,8 +272,10 @@
 
                if (multi > 0) glColor4f(0,0,dy0,dy0);
                colorfv(c0);
+               colorfv2(c1);
                texCoord(vert1[i][0], texscale);
                u = GL_TEXTURE1;
+               if (flags & SLICE_2D) multiTexCoord(u, vert[i][0], texscale);
                for (int d = 1; d <= multi; d++) {
                    multiTexCoord(u++, pt[i] + d * d0, texscale);
                    multiTexCoord(u++, pt[i] - d * d0, texscale);
@@ -277,8 +290,10 @@
                }
 
                //colorfv(c0);
+               //colorfv2(c1);
                texCoord(vert1[j][0], texscale);
                u = GL_TEXTURE1;
+               if (flags & SLICE_2D) multiTexCoord(u, vert[j][0], texscale);
                for (int d = 1; d <= multi; d++) {
                    multiTexCoord(u++, pt[j] + d * d0, texscale);
                    multiTexCoord(u++, pt[j] - d * d0, texscale);
@@ -287,8 +302,10 @@
                
                if (multi > 0) glColor4f(0,0,dy1,dy1);
                colorfv(c0 + 4);
+               colorfv2(c1 + 4);
                texCoord(b1q, texscale * q1);
                u = GL_TEXTURE1;
+               if (flags & SLICE_2D) multiTexCoord(u, vert[j][1], texscale);
                for (int d = 1; d <= multi; d++) {
                    multiTexCoord(u++, b1q + d * q1 * d1, texscale * q1);
                    multiTexCoord(u++, b1q - d * q1 * d1, texscale * q1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]