[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz doc/pegboard/201/PEG_201.rst gfx/demo/vpbuo...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz doc/pegboard/201/PEG_201.rst gfx/demo/vpbuo... |
Date: |
Sun, 15 Dec 2002 15:08:42 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/12/15 15:08:42
Modified files:
doc/pegboard/201: PEG_201.rst
gfx/demo : vpbuoy.py
Log message:
Try Cg
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/doc/pegboard/201/PEG_201.rst.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/vpbuoy.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: gzz/doc/pegboard/201/PEG_201.rst
diff -u gzz/doc/pegboard/201/PEG_201.rst:1.11
gzz/doc/pegboard/201/PEG_201.rst:1.12
--- gzz/doc/pegboard/201/PEG_201.rst:1.11 Sat Dec 14 03:11:34 2002
+++ gzz/doc/pegboard/201/PEG_201.rst Sun Dec 15 15:08:41 2002
@@ -4,8 +4,8 @@
:Authors: Tuomas Lukka
:Stakeholders: Asko Soukka
-:Last-Modified: $Date: 2002/12/14 08:11:34 $
-:Revision: $Revision: 1.11 $
+:Last-Modified: $Date: 2002/12/15 20:08:41 $
+:Revision: $Revision: 1.12 $
:Status: Incomplete
This META-PEG deals with formatting PEGs.
@@ -171,6 +171,15 @@
An adjustment of one or more interfaces; e.g. ``1017``
Implementation
An adjustment of how an implementation does something
+
+Affects-PEGs
+
+ A comma-separated list of the PEGs that this PEG affects: since
+ accepted PEGs may not be modified, this field explains which
+ PEGs define behaviour that is to be modified by this PEG.
+
+ The idea is that the reST compiler would take this into account
+ and mention the affecting PEGs in a compiled PEG.
Low-level Format
----------------
Index: gzz/gfx/demo/vpbuoy.py
diff -u gzz/gfx/demo/vpbuoy.py:1.4 gzz/gfx/demo/vpbuoy.py:1.5
--- gzz/gfx/demo/vpbuoy.py:1.4 Sun Dec 15 04:06:46 2002
+++ gzz/gfx/demo/vpbuoy.py Sun Dec 15 15:08:42 2002
@@ -1,5 +1,5 @@
from gfx.util.misc import *
-from gfx.util import vparb
+from gfx.util import vparb, cg
class Scene:
@@ -12,137 +12,188 @@
rad = 400.0
recrad = 1/400.0
- if 0:
- func = """
- # Shift
- TEMP shift;
- MUL shift, cent, radius.y;
- """
- else:
- func = """
-
- PARAM lines[] = {
- { -100, -100, 1, 0 },
- { 0, 0, .1, 0 },
- { .2, .02, 9, 0 },
- { .3, .92, .1, 0 },
- { .75, 1, 1, 0 }
- };
-
- TEMP var;
- SUB var, amplen, absamo;
- ADD var, var, 1;
- MUL var, var, .5;
-
- ADDRESS iadr;
- TEMP ind;
- SGE ind.x, var, lines[1].x;
- SGE ind.y, var, lines[2].x;
- SGE ind.z, var, lines[3].x;
- SGE ind.w, var, lines[4].x;
- DP4 ind, ind, ind;
- ARL iadr.x, ind.x;
-
- # Shift
- TEMP shift;
- MOV shift, var;
-
- SUB shift, var, lines[iadr.x].x;
- MUL shift, shift, lines[iadr.x].z;
- ADD shift, shift, lines[iadr.x].y;
-
-
- SUB shift, shift, var;
-
- # See where we fall; 5 line pieces
-
- MUL shift, shift, radius.y;
- """
-
- self.prog = GL.createProgram("""!!ARBvp1.0
-
- # x,y = coordinates
- # z = 0: no shift, 1 = shift
- # w = 0
- ATTRIB orig = vertex.position;
+ if 1:
+ cgprog = """
+ struct outs {
+ float4 pos : POSITION;
+ float4 color : COLOR;
+ float4 pointsize : PSIZE;
+ };
+ float4x4 pmat;
- PARAM center = { 512, 350, 0, 0 };
- PARAM p = { 112, 350, 0, 0 };
- PARAM radius = { %(recrad)s, %(rad)s, 0, 0 };
- PARAM zeroone = { 0, 1, 5, 0 };
+ outs main( float4 orig : POSITION,
+ float4 texcoord : TEXCOORD0,
+ float4 color : COLOR
+ ) {
+ float4 p = { 100, 300, 0, 0 };
+ float4 origin = { 300, 300, 0, 0};
+ float rad = 200;
+ outs o;
- PARAM pm[4] = { state.matrix.program[0] };
- PARAM mvp[4] = { state.matrix.mvp };
+ float4x4 pmat = glstate.matrix.program[0];
- TEMP anchor;
- DP4 anchor.x, pm[0], orig;
- DP4 anchor.y, pm[1], orig;
- MOV anchor.z, orig.z;
- MOV anchor.w, 0;
+ float4 anchor = mul(pmat, orig);
- # A - O
- TEMP amo;
- MOV amo, zeroone.x;
- SUB amo.xy, anchor, center;
+ float a2o = distance(anchor.xy, origin.xy) / rad;
- # | A - O |
- TEMP absamo;
- DP3 absamo, amo, amo;
- RSQ absamo.x, absamo.x;
- MUL absamo, absamo.x, absamo.y;
- MUL absamo, absamo, radius.x;
+ float4 buoy;
- # cent = 1-|A-O|
- TEMP cent;
- SUB cent, zeroone.y, absamo.x;
- MAX cent, cent, 0;
+ buoy = anchor;
- TEMP scale;
- ADD scale, cent, zeroone.y;
+ o.pos = mul(glstate.matrix.mvp, buoy);
+ o.color = float4(color.x, color.y, a2o, color.w);
+ o.pointsize = float4(15.0, 0, 0, 0);
- TEMP amp;
- SUB amp, anchor, p;
-
- TEMP ampnor;
- TEMP amplen;
- DP3 amplen, amp, amp;
- RSQ ampnor, amplen.x;
- MUL amplen, amplen.x, ampnor.x;
- MUL amplen, amplen.x, radius.x;
- MUL ampnor, ampnor, amp;
-
- # Function to determine shift
- %(func)s
-
- MUL shift, shift, anchor.z;
-
- # buoy position
- TEMP buoy;
- MAD buoy, ampnor, shift, anchor;
-
- MOV buoy.zw, zeroone.xyxy;
- ADD buoy.z, buoy.z, -scale;
-
- ADD buoy.xyz, buoy, vertex.texcoord[0];
+ return o;
+ }
+ """
+ pstr = cg.compile_arbvp1(cgprog)
+ # fix a really silly compiler bug
+ # For some reason, only the mvp matrix works,
+ # the others produce this type of garbage in the output.
+ pstr = pstr.replace("s327[32]", "s327[4]")
+ pstr = pstr.replace("s0[327]", "s327[0]")
+ pstr = pstr.replace("s328", "s327[1]")
+ pstr = pstr.replace("s329", "s327[2]")
+ pstr = pstr.replace("s330", "s327[3]")
- DP4 result.position.x, mvp[0], buoy;
- DP4 result.position.y, mvp[1], buoy;
- DP4 result.position.z, mvp[2], buoy;
- DP4 result.position.w, mvp[3], buoy;
+ self.prog = GL.createProgram(pstr)
+
- # MOV result.color, vertex.color;
- SWZ result.color, cent, x, x, x, 1;
+ else:
- ALIAS ps0 = anchor;
- MAD ps0, zeroone.z, anchor.z, zeroone.z;
- MUL result.pointsize, scale, ps0;
+ if 0:
+ func = """
+ # Shift
+ TEMP shift;
+ MUL shift, cent, radius.y;
+ """
+ else:
+ func = """
+
+ PARAM lines[] = {
+ { -100, -100, 1, 0 },
+ { 0, 0, .1, 0 },
+ { .2, .02, 9, 0 },
+ { .3, .92, .1, 0 },
+ { .75, 1, 1, 0 }
+ };
+
+ TEMP var;
+ SUB var, amplen, absamo;
+ ADD var, var, 1;
+ MUL var, var, .5;
+
+ ADDRESS iadr;
+ TEMP ind;
+ SGE ind.x, var, lines[1].x;
+ SGE ind.y, var, lines[2].x;
+ SGE ind.z, var, lines[3].x;
+ SGE ind.w, var, lines[4].x;
+ DP4 ind, ind, ind;
+ ARL iadr.x, ind.x;
+
+ # Shift
+ TEMP shift;
+ MOV shift, var;
+
+ SUB shift, var, lines[iadr.x].x;
+ MUL shift, shift, lines[iadr.x].z;
+ ADD shift, shift, lines[iadr.x].y;
+
+
+ SUB shift, shift, var;
+
+ # See where we fall; 5 line pieces
+
+ MUL shift, shift, radius.y;
+ """
+
+ self.prog = GL.createProgram("""!!ARBvp1.0
+
+ # x,y = coordinates
+ # z = 0: no shift, 1 = shift
+ # w = 0
+ ATTRIB orig = vertex.position;
+
+ PARAM center = { 512, 350, 0, 0 };
+ PARAM p = { 112, 350, 0, 0 };
+ PARAM radius = { %(recrad)s, %(rad)s, 0, 0 };
+ PARAM zeroone = { 0, 1, 5, 0 };
+
+
+ PARAM pm[4] = { state.matrix.program[0] };
+ PARAM mvp[4] = { state.matrix.mvp };
+
+ TEMP anchor;
+ DP4 anchor.x, pm[0], orig;
+ DP4 anchor.y, pm[1], orig;
+ MOV anchor.z, orig.z;
+ MOV anchor.w, 0;
+
+ # A - O
+ TEMP amo;
+ MOV amo, zeroone.x;
+ SUB amo.xy, anchor, center;
+
+ # | A - O |
+ TEMP absamo;
+ DP3 absamo, amo, amo;
+ RSQ absamo.x, absamo.x;
+ MUL absamo, absamo.x, absamo.y;
+ MUL absamo, absamo, radius.x;
+
+ # cent = 1-|A-O|
+ TEMP cent;
+ SUB cent, zeroone.y, absamo.x;
+ MAX cent, cent, 0;
+
+ TEMP scale;
+ ADD scale, cent, zeroone.y;
+
+ TEMP amp;
+ SUB amp, anchor, p;
+
+ TEMP ampnor;
+ TEMP amplen;
+ DP3 amplen, amp, amp;
+ RSQ ampnor, amplen.x;
+ MUL amplen, amplen.x, ampnor.x;
+ MUL amplen, amplen.x, radius.x;
+ MUL ampnor, ampnor, amp;
+
+ # Function to determine shift
+ %(func)s
+
+ MUL shift, shift, anchor.z;
+
+ # buoy position
+ TEMP buoy;
+ MAD buoy, ampnor, shift, anchor;
+
+ MOV buoy.zw, zeroone.xyxy;
+ ADD buoy.z, buoy.z, -scale;
+
+ ADD buoy.xyz, buoy, vertex.texcoord[0];
+
+ DP4 result.position.x, mvp[0], buoy;
+ DP4 result.position.y, mvp[1], buoy;
+ DP4 result.position.z, mvp[2], buoy;
+ DP4 result.position.w, mvp[3], buoy;
+
+ # MOV result.color, vertex.color;
+ SWZ result.color, cent, x, x, x, 1;
+
+ ALIAS ps0 = anchor;
+ MAD ps0, zeroone.z, anchor.z, zeroone.z;
+ MUL result.pointsize, scale, ps0;
- END
+ END
- """ % locals())
+ """ % locals())
vparb.dump(self.prog.getProgId())
if 0: self.prog = GL.createProgram("""!!ARBvp1.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz doc/pegboard/201/PEG_201.rst gfx/demo/vpbuo...,
Tuomas J. Lukka <=