gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx/demo irregu3.py


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx/demo irregu3.py
Date: Tue, 29 Oct 2002 11:52:33 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/10/29 11:52:32

Modified files:
        gfx/demo       : irregu3.py 

Log message:
        Multitexture profile works; requires three texture units and four 
general combiners

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.32&tr2=1.33&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.32 gzz/gfx/demo/irregu3.py:1.33
--- gzz/gfx/demo/irregu3.py:1.32        Tue Oct 29 11:34:04 2002
+++ gzz/gfx/demo/irregu3.py     Tue Oct 29 11:52:32 2002
@@ -174,8 +174,6 @@
             using_multitex = 1
             texenv_inner = texenv % "0 0 0 1"
             texenv_outer = combinercode("""
-            Color 0 0 0 0
-        
             # compute alpha = max( SEC_COL.b + TEX0 + COL.alpha + COL.b,
             #                      SEC_COL.b + TEX1 + COL.alpha,
             #                      SEC_COL.b + TEX2 + COL.alpha )
@@ -385,24 +383,42 @@
     else:
         assert(0)
 
-    if using_shader:
-        dx = -cos(angle)
-        dy = -sin(angle)
+    code = """
+    PushAttrib ENABLE_BIT TEXTURE_BIT
 
-        texcoords += [ [ (0, 0, 0),
-                         (0, 0, 0),
-                         (0, 0, striplen / texscale * edgetexsize),
-                         (0, 0, striplen / texscale * edgetexsize),
-                         ],
-                       [ (dx,dy,0-.5*(dx+dy)),
-                         (dx,dy,1-.5*(dx+dy)),
-                         (dx,dy,0-.5*(dx+dy)),
-                         (dx,dy,1-.5*(dx+dy)),
-                         ]
-                       ]
+    BindTexture TEXTURE_2D %(texid)s
+    TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
+    TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
+    Enable TEXTURE_2D
+    """ % locals()
 
     if using_multitex and outer:
-        t = .01
+        # XXX: scaling doesn't work properly because the coordinate
+        #      transformation is not known here
+        #
+        # t:     distance between texcoords
+        # alpha: value added to the displacement values
+        # blue:  value added to the middle displacement (in addition to alpha)
+        t = 1./256
+        alpha = 6./256
+        blue = 4./256
+        
+        code += """
+        ActiveTexture TEXTURE1
+        BindTexture TEXTURE_2D %(texid)s
+        TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
+        TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
+        Enable TEXTURE_2D
+        ActiveTexture TEXTURE2
+        BindTexture TEXTURE_2D %(texid)s
+        TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
+        TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
+        Enable TEXTURE_2D
+        ActiveTexture TEXTURE0
+
+        Color 0 0 %(blue)s %(alpha)s
+        """ % locals()
+
         dx = cos(angle) * t
         dy = sin(angle) * t
         
@@ -418,6 +434,23 @@
                          ]
                        ]
 
+
+    if using_shader:
+        dx = -cos(angle)
+        dy = -sin(angle)
+
+        texcoords += [ [ (0, 0, 0),
+                         (0, 0, 0),
+                         (0, 0, striplen / texscale * edgetexsize),
+                         (0, 0, striplen / texscale * edgetexsize),
+                         ],
+                       [ (dx,dy,0-.5*(dx+dy)),
+                         (dx,dy,1-.5*(dx+dy)),
+                         (dx,dy,0-.5*(dx+dy)),
+                         (dx,dy,1-.5*(dx+dy)),
+                         ]
+                       ]
+
     vec = [ 0 for i in range(0, angles) ]
 
     if angles:
@@ -447,30 +480,6 @@
              colmap1(vec),
              ]
     
-    code = """
-    PushAttrib ENABLE_BIT TEXTURE_BIT
-
-    BindTexture TEXTURE_2D %(texid)s
-    TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
-    TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
-    Enable TEXTURE_2D
-    """ % locals()
-
-    if using_multitex and outer:
-        code += """
-        ActiveTexture TEXTURE1
-        BindTexture TEXTURE_2D %(texid)s
-        TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
-        TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
-        Enable TEXTURE_2D
-        ActiveTexture TEXTURE2
-        BindTexture TEXTURE_2D %(texid)s
-        TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
-        TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
-        Enable TEXTURE_2D
-        ActiveTexture TEXTURE0
-        """ % locals()
-    
     if GL.hasExtension("GL_EXT_texture_lod_bias"):
         code += """
         TexEnv TEXTURE_FILTER_CONTROL_EXT TEXTURE_LOD_BIAS_EXT %s
@@ -630,6 +639,21 @@
                                        -sin(self.angle), cos(self.angle))
         vs.matcher.add(cs4, "4")
         vs.map.put(GLRen.createTextureMatrix(), cs4)
+        if using_multitex:
+            vs.map.put(getDListNocoords("ActiveTexture TEXTURE1"))
+            vs.map.put(GLRen.createTextureMatrix(), cs4)
+            vs.map.put(getDListNocoords("ActiveTexture TEXTURE2"))
+            vs.map.put(GLRen.createTextureMatrix(), cs4)
+            vs.map.put(getDListNocoords("ActiveTexture TEXTURE0"))
+        elif using_shader:
+            vs.map.put(getDListNocoords("""
+            ActiveTexture TEXTURE2
+            PushAttrib TRANSFORM_BIT
+            MatrixMode TEXTURE
+            LoadIdentity
+            PopAttrib
+            ActiveTexture TEXTURE0
+            """))
 
         vs.map.put(getDListNocoords("""
             PushMatrix




reply via email to

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