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 libtexture/irreguedge.t...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/irregu3.py libtexture/irreguedge.t...
Date: Mon, 28 Oct 2002 09:19:46 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/10/28 09:19:46

Modified files:
        gfx/demo       : irregu3.py 
        gfx/libtexture : irreguedge.texture 

Log message:
        Use irregu3 shader version with alpha_test and stencil, too

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/irregu3.py.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/irreguedge.texture.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/irregu3.py
diff -u gzz/gfx/demo/irregu3.py:1.24 gzz/gfx/demo/irregu3.py:1.25
--- gzz/gfx/demo/irregu3.py:1.24        Mon Oct 28 04:54:56 2002
+++ gzz/gfx/demo/irregu3.py     Mon Oct 28 09:19:46 2002
@@ -42,11 +42,24 @@
 
         using_shader = 1
         global use_stencil
-        use_stencil = 0
-        edgetex = getCachedTexture([1, edgetexsize, 0, 4, "RGBA", "RGBA",
-                                    "irreguedge", ["line_width", "1"]], 
shade_all_levels = 1)
+        #use_stencil = 0
+        edgetex_inner = getCachedTexture(
+            [1, edgetexsize, 0, 1, "ALPHA", "ALPHA", "irreguedge",
+             ["line_width", "2",
+              "col0", "1",
+              "col1", "0",
+              "col2", "0"]],
+            shade_all_levels = 1)
+        
+        edgetex_outer = getCachedTexture(
+            [1, edgetexsize, 0, 1, "ALPHA", "ALPHA", "irreguedge",
+             ["line_width", "2",
+              "col0", "1",
+              "col1", "1",
+              "col2", "0"]],
+            shade_all_levels = 1)
         
-        texenv_inner = """
+        texenv = """
         Enable TEXTURE_SHADER_NV
         
         TexEnv TEXTURE_SHADER_NV SHADER_OPERATION_NV TEXTURE_2D
@@ -67,13 +80,12 @@
         TexParameter TEXTURE_2D TEXTURE_WRAP_T CLAMP
 
         ActiveTexture TEXTURE0
+        """ 
 
-        Disable ALPHA_TEST
-        """ % edgetex.getTexId()
-
-        texenv_outer = texenv_inner
+        texenv_inner = texenv % edgetex_inner.getTexId()
+        texenv_outer = texenv % edgetex_outer.getTexId()
 
-        alphalevel = None
+        alphalevel = 1
         w0,w1 = 1,1
         def colmap0(dotvec): return (1,1,1)
         def colmap1(dotvec): return (1,1,1)
@@ -210,8 +222,8 @@
     if k == "b": lodbias += .25; print "lodbias", lodbias
     elif k == "B": lodbias -= .25; print "lodbias", lodbias
     global edgelodbias
-    if k == "e": edgelodbias += .25; print "lodbias", edgelodbias
-    elif k == "E": edgelodbias -= .25; print "lodbias", edgelodbias
+    if k == "e": edgelodbias += .25; print "edgelodbias", edgelodbias
+    elif k == "E": edgelodbias -= .25; print "edgelodbias", edgelodbias
     global texscale
     if k == "s": texscale *= 1.2; print "texscale", texscale
     elif k == "S": texscale /= 1.2; print "texscale", texscale
@@ -255,8 +267,8 @@
 
     angle = atan2(y1 - y0, x1 - x0) - texangle
 
-    dx = cos(angle)
-    dy = sin(angle)
+    dx = -cos(angle)
+    dy = -sin(angle)
 
     if using_shader:
         texcoords += [ [ (0, 0, 0),
@@ -379,9 +391,10 @@
         self.scale = texsize
         self.angle = 0
         self.tx, self.ty = 0, 0
+        self.bg = background((0.7,0.7,1.0))
         
     def scene(self, vs):
-        putnoc(vs, background((0.7,0.7,1.0)))
+        putnoc(vs, self.bg)
 
         global scale
         scale = self.scale
@@ -449,7 +462,7 @@
             MultMatrix  %s
         """ % matrices[0]))
 
-        if not using_shader:
+        if use_stencil:
             vs.map.put(getDList(getIrregu(0,x0,-1,x1,-1,1, texscale, 
self.angle) +
                                 getIrregu(0,+1,y0,+1,y1,1, texscale, 
self.angle) +
                                 getIrregu(1,x1,+1,x0,+1,1, texscale, 
self.angle) +
Index: gzz/gfx/libtexture/irreguedge.texture
diff -u gzz/gfx/libtexture/irreguedge.texture:1.1 
gzz/gfx/libtexture/irreguedge.texture:1.2
--- gzz/gfx/libtexture/irreguedge.texture:1.1   Sat Oct 26 10:09:53 2002
+++ gzz/gfx/libtexture/irreguedge.texture       Mon Oct 28 09:19:46 2002
@@ -1,5 +1,6 @@
 // -*-C++-*-
 #include <math.h>
+#include <stdio.h>
 
 #define FPARAM(name, default) float name = params->getFloat(#name, default);
 
@@ -7,10 +8,23 @@
 void GENERATE(TextureParam *params, int width, int height, int depth, int 
components, float *data) {
     FPARAM(bias, 0);
     FPARAM(scale, 1);
-    FPARAM(radius, 0.75);
-    
     FPARAM(line_width, 2);
 
+    float col[3][4] = {
+        { 1, 1, 1, 1 },
+        { 0, 0, 0, 1 },
+        { 0, 0, 0, 0 }
+    };
+
+    sscanf(params->getString("col0", "1,1,1,1"), "%f,%f,%f,%f", 
+          &col[0][0], &col[0][1], &col[0][2], &col[0][3]);
+
+    sscanf(params->getString("col1", "0,0,0,1"), "%f,%f,%f,%f", 
+          &col[1][0], &col[1][1], &col[1][2], &col[1][3]);
+
+    sscanf(params->getString("col2", "0,0,0,0"), "%f,%f,%f,%f", 
+          &col[2][0], &col[2][1], &col[2][2], &col[2][3]);
+
     int ind=0, i, j;
     float x, y;
     float xstep = 1.0 / width;
@@ -18,19 +32,17 @@
 
     ind = 0;
 
+
     for (j = 0, y = 0; j < height; j++, y += ystep) {  
        for (i = 0, x = 0; i < width; i++, x += xstep) {
-           float c = 0.5, a = 1;
-           
-           if (j < height/2 + line_width) c = 0;
-           if (j < height/2) c = 1;
-           //a = 1;
-           //c = y;
-
-           if (components >= 1) data[ind++] = c * scale + bias;
-           if (components >= 2) data[ind++] = c * scale + bias;
-           if (components >= 3) data[ind++] = c * scale + bias;
-           if (components >= 4) data[ind++] = a * scale + bias;
+           int pos = 2;
+           if (j < height/2 + line_width) pos = 1;
+           if (j < height/2) pos = 0;
+
+           if (components >= 1) data[ind++] = col[pos][0] * scale + bias;
+           if (components >= 2) data[ind++] = col[pos][1] * scale + bias;
+           if (components >= 3) data[ind++] = col[pos][2] * scale + bias;
+           if (components >= 4) data[ind++] = col[pos][3] * scale + bias;
        }       
     }
     




reply via email to

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