gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/vpbuoy.py libcallgl/callgl.cxx lib...


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx demo/vpbuoy.py libcallgl/callgl.cxx lib...
Date: Mon, 16 Dec 2002 07:52:23 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/12/16 07:52:23

Modified files:
        gfx/demo       : vpbuoy.py 
        gfx/libcallgl  : callgl.cxx callgl.hxx 

Log message:
        More vp work

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/vpbuoy.py.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.23&tr2=1.24&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/vpbuoy.py
diff -u gzz/gfx/demo/vpbuoy.py:1.6 gzz/gfx/demo/vpbuoy.py:1.7
--- gzz/gfx/demo/vpbuoy.py:1.6  Mon Dec 16 02:03:15 2002
+++ gzz/gfx/demo/vpbuoy.py      Mon Dec 16 07:52:23 2002
@@ -4,7 +4,7 @@
 
 class Scene:
     """A vertex program version of buoys for exploring
-    1) vertex programs, 2) buoy geometry.
+    1) vertex programs, 2) buoy geometry, 3) Cg.
 
     Not for real use.
     """
@@ -21,12 +21,52 @@
            };
            float4x4 pmat;
 
-           outs main( float4 orig : POSITION, 
+           float2 anchorPlace(float4 orig) {
+               float4x4 pmat = glstate.matrix.program[0];
+               float div = dot(pmat[3], orig);
+               return float2(
+                   dot(pmat[0], orig) / div,
+                   dot(pmat[1], orig) / div
+               );
+           }
+
+           outs main(
+                   float4 orig : POSITION, 
                    float4 texcoord : TEXCOORD0,
-                   float4 color : COLOR
+                   float4 color : COLOR,
+                   uniform float4 p : C0,
+                   uniform float4 origin : C1
                    ) {
-               float4 p = { 100, 350, 0, 0 };
-               float4 origin = { 500, 350, 0, 0};
+               outs o;
+               float rad = 400;
+               float2 anchor = anchorPlace(orig);
+
+               float2 ap = anchor.xy - origin.xy;
+               float aplen = length(ap);
+               float2 apnor = ap / aplen;
+
+               float2 opnor = normalize(origin.xy - p.xy);
+
+               float4 buoy;
+               buoy.xy = anchor + orig.z * (10 * opnor);
+               buoy.z = 1-orig.z;
+               buoy.w = 1;
+
+               o.pos = mul(glstate.matrix.mvp, buoy);
+               o.pointsize = float4(4. + 4. * orig.z, 0, 0, 0);
+               o.color = color;
+               return o;
+           }
+
+           outs foo(
+                   float4 orig : POSITION, 
+                   float4 texcoord : TEXCOORD0,
+                   float4 color : COLOR,
+                   uniform float4 p : C0,
+                   uniform float4 origin : C1
+                   ) {
+               // float4 p = { 100, 350, 0, 0 };
+               // float4 origin = { 500, 350, 0, 0};
                float rad = 400;
 
                outs o;
@@ -40,19 +80,40 @@
                float w = dot(pmat[3],  orig);
                anchor /= w;
 
+
                float a2o = distance(anchor.xy, origin.xy) / rad;
                float2 ap ;
                ap.xy = anchor.xy - p.xy;
                float a2p = length(ap) / rad;
 
+               // first coordinate
+               float c1 = (a2o < 1 ? a2p / 2 : 0);
+
+               // Two separate locations
+               float s1 = .9 * (1-c1);
+               float s2 = max(0, -1 +  10*c1);
+
+               float ctrhat = max(0, 1-a2o);
+
+               float shift = .4 * ctrhat / a2p;
+
+               // the "default" position
+               float2 defbuoy = anchor + ap * shift;
+
+               float d2o = distance(defbuoy.xy, origin.xy) / rad;
+               // float dir = 2.*(
+               float dir = dot(defbuoy.xy - origin.xy, ap.xy) > 0 ? 1 : -1;
+               // Push away
+               shift = 0.6 * dir * ctrhat ;
+
                float4 buoy;
+               buoy.xy = anchor + orig.z *  (ap * shift + .1 * (origin.xy - 
p.xy));
 
-               buoy.xy = anchor + orig.z * .5 * ap * max(0,1-a2o);
                buoy.z = 1-orig.z;
                buoy.w = 1;
 
                o.pos = mul(glstate.matrix.mvp, buoy);
-               o.color = float4(1-orig.z, a2o, a2p, color.w);
+               o.color = float4(1-orig.z, dir, dir, color.w);
                o.pointsize = float4(4. + 4. * orig.z, 0, 0, 0);
 
                return o;
@@ -236,8 +297,8 @@
                        Vertex %(x)s %(y)s 1 1
                    """ % locals())
        else:
-           for i in range(0,4000):
-               x, y = java.lang.Math.random(), java.lang.Math.random()
+           for i in range(0,500):
+               x, y = [2*java.lang.Math.random()-1 for i in (0,1)]
                vert.append("""
                    Color %(x)s .0 %(y)s .6
                    Vertex %(x)s %(y)s 0 1
@@ -300,14 +361,25 @@
        if self.showmapping: 
            vs.put(GLRen.createSetMatrix("MATRIX0_ARB"), "M", 0,
                0, 350, 1, 1)
-           vs.put(self.linep, "G", 0, 0, 0, 1, 1)
+           vs.map.put(self.linep, 0)
        else:
-           vs.put(GLRen.createSetMatrix("MATRIX0_ARB"), "M", 0,
-               -300+Math.random() * 300, -300+Math.random() * 300,
-               1400 + Math.random() * 400, 1400 + Math.random() * 400,
+           cs = vs.orthoCS(0, "M", 0,
+               -200+Math.random() * 200, -200+Math.random() * 200,
+               1200 + Math.random() * 600, 1200 + Math.random() * 600,
                )
+           cs = vs.orthoCS(cs, "F", 0, .5, .5, .5, .5)
+           vs.map.put(GLRen.createSetMatrix("MATRIX0_ARB"), cs)
 
-           vs.put(self.pointlist, "F", 0, 0, 0, 1, 1)
+           putnoc(vs, getDListNocoords("""
+               ProgramLocalParameter VERTEX_PROGRAM_ARB 0 100 350 0 0
+               ProgramLocalParameter VERTEX_PROGRAM_ARB 1 500 350 0 0
+           """))
+           vs.map.put(self.pointlist, 0)
+           putnoc(vs, getDListNocoords("""
+               ProgramLocalParameter VERTEX_PROGRAM_ARB 0 900 350 0 0
+               ProgramLocalParameter VERTEX_PROGRAM_ARB 1 500 350 0 0
+           """))
+           vs.map.put(self.pointlist, 0)
 
        putnoc(vs, getDListNocoords("""
                BindProgram VERTEX_PROGRAM_ARB 0
Index: gzz/gfx/libcallgl/callgl.cxx
diff -u gzz/gfx/libcallgl/callgl.cxx:1.39 gzz/gfx/libcallgl/callgl.cxx:1.40
--- gzz/gfx/libcallgl/callgl.cxx:1.39   Sat Dec 14 03:11:34 2002
+++ gzz/gfx/libcallgl/callgl.cxx        Mon Dec 16 07:52:23 2002
@@ -314,9 +314,8 @@
                       getTokenf(v[2]),
                       getTokenf(v[3]),
                       getTokenf(v[4]));
-       } else if (checkfunc(v, "ActiveTextureARB", 1)) {
-         glActiveTextureARB(getToken(v[1]));
-       } else if (checkfunc(v, "ActiveTexture", 1)) {
+       } else if (checkfunc(v, "ActiveTextureARB", 1) ||
+                   checkfunc(v, "ActiveTexture", 1) ) {
          glActiveTextureARB(getToken(v[1]));
        } else if (checkfunc(v, "Begin", 1)) {
          glBegin(getToken(v[1]));
@@ -486,9 +485,35 @@
            glEvalMapsNV(getToken(v[1]), getToken(v[2]));
 #endif
 
-#ifdef GL_VERTEX_PROGRAM_NV
-       } else if (checkfunc(v, "BindProgram", 2)) {
+#ifdef GL_VERTEX_PROGRAM_ARB
+       } else if (checkfunc(v, "BindProgram", 2) ||
+                   checkfunc(v, "BindProgramARB", 2)
+               ) {
          glBindProgramARB(getToken(v[1]), (GLuint)getToken(v[2]));
+       } else if (checkfunc(v, "ProgramLocalParameter", 6) ||
+                   checkfunc(v, "ProgramLocalParameterARB", 6)
+               ) {
+           glProgramLocalParameter4fARB(
+                   getToken(v[1]),
+                   getToken(v[2]),
+                   getTokenf(v[3]),
+                   getTokenf(v[4]),
+                   getTokenf(v[5]),
+                   getTokenf(v[6]));
+       } else if (checkfunc(v, "ProgramEnvParameter", 6) ||
+                   checkfunc(v, "ProgramEnvParameterARB", 6)
+               ) {
+           glProgramEnvParameter4fARB(
+                   getToken(v[1]),
+                   getToken(v[2]),
+                   getTokenf(v[3]),
+                   getTokenf(v[4]),
+                   getTokenf(v[5]),
+                   getTokenf(v[6]));
+
+#endif
+
+#ifdef GL_VERTEX_PROGRAM_NV
        } else if (checkfunc(v, "BindProgramNV", 2)) {
          glBindProgramNV(getToken(v[1]), (GLuint)getToken(v[2]));
        } else if (checkfunc(v, "TrackMatrixNV", 4)) {
Index: gzz/gfx/libcallgl/callgl.hxx
diff -u gzz/gfx/libcallgl/callgl.hxx:1.23 gzz/gfx/libcallgl/callgl.hxx:1.24
--- gzz/gfx/libcallgl/callgl.hxx:1.23   Sat Dec 14 03:11:34 2002
+++ gzz/gfx/libcallgl/callgl.hxx        Mon Dec 16 07:52:23 2002
@@ -34,7 +34,16 @@
      *                 TexEnv TEXTURE_ENV TEXTURE_ENV_COLOR 1 0.5 0.5 0.2
      *                 Enable BLEND
      *         </pre>  
-     * i.e. the gl, GL_ etc prefixes are omitted. In the first stage,
+     * i.e. the gl, GL_ etc prefixes are omitted. 
+     * Also, for ARB extensions, the ARB suffix on function names
+     * (but not on tokens!) can be omitted:
+     * <pre>
+     *                 BindProgramARB VERTEX_PROGRAM_ARB 4
+     *                 BindProgram VERTEX_PROGRAM_ARB 4
+     *                 BindProgram VERTEX_PROGRAM 4 # --- ILLEGAL
+     * </pre>
+     * <p>
+     * In the first stage,
      * the functions
      * <pre>
      *                 TexEnv
@@ -68,7 +77,9 @@
      *                 ProgramParameterNV
      *                 TrackMatrixNV
      * </pre>
-     * shall be supported.
+     * shall be supported. (there are now much more; document XXX !!!)
+     * <p>
+     *
      */
     void callGL(const char *string, int intoList);
 



reply via email to

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