gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob include/vob/jni/Types.hxx include/vob/vo...


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob include/vob/jni/Types.hxx include/vob/vo...
Date: Fri, 11 Apr 2003 16:41:24 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/04/11 16:41:24

Modified files:
        include/vob/jni: Types.hxx 
        include/vob/vobs: Program.hxx 
        vob/demo       : fpfont.py 
Added files:
        vob/putil      : cg.py 

Log message:
        Cg version of font renderer

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/jni/Types.hxx.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Program.hxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/fpfont.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/cg.py?rev=1.1

Patches:
Index: libvob/include/vob/jni/Types.hxx
diff -u libvob/include/vob/jni/Types.hxx:1.19 
libvob/include/vob/jni/Types.hxx:1.20
--- libvob/include/vob/jni/Types.hxx:1.19       Fri Apr  4 07:34:59 2003
+++ libvob/include/vob/jni/Types.hxx    Fri Apr 11 16:41:24 2003
@@ -172,6 +172,10 @@
        out = jstr2unistr(env, in);
     END_VOB_JNI_CONVERSION
 
+    START_VOB_JNI_CONVERSION(std::string, "String", jstring)
+       out = jstr2stdstr(env, in);
+    END_VOB_JNI_CONVERSION
+
 
     START_VOB_JNI_CONVERSION_IDDED(GLubyte *, "GL.ByteVector")
        DBG(dbg_convert) << "Converting bytevec "<<in<<"\n";
Index: libvob/include/vob/vobs/Program.hxx
diff -u libvob/include/vob/vobs/Program.hxx:1.1 
libvob/include/vob/vobs/Program.hxx:1.2
--- libvob/include/vob/vobs/Program.hxx:1.1     Wed Apr  9 11:05:24 2003
+++ libvob/include/vob/vobs/Program.hxx Fri Apr 11 16:41:24 2003
@@ -30,7 +30,30 @@
        }
     };
 
-VOB_DEFINED(ProgramLocalParameterARB);
+    VOB_DEFINED(ProgramLocalParameterARB);
+
+    class ProgramNamedParameterNV {
+    public:
+       enum { NTrans = 1 };
+
+       int id;
+       std::string name;
+       template<class F> void params(F &f) {
+           f(id, name);
+       }
+       template<class T> void render(const T &t) const {
+           ZPt p1 = t.transform(ZPt(0,0,0));
+           ZPt p2 = t.transform(ZPt(1,1,0));
+           glProgramNamedParameter4fNV(
+                   id, 
+                   name.length(),
+                   (const GLubyte *)name.data(),
+                   p1.x, p1.y, p2.x-p1.x, p2.y-p2.x);
+       }
+    };
+
+    VOB_DEFINED(ProgramNamedParameterNV);
+
 
 }
 }
Index: libvob/vob/demo/fpfont.py
diff -u libvob/vob/demo/fpfont.py:1.3 libvob/vob/demo/fpfont.py:1.4
--- libvob/vob/demo/fpfont.py:1.3       Fri Apr 11 08:52:51 2003
+++ libvob/vob/demo/fpfont.py   Fri Apr 11 16:41:24 2003
@@ -93,8 +93,67 @@
 
 # 16 * texel [1/512]
 
-fp = [
+from vob.putil import cg
+
+fp = [GL.createProgram(cg.compile("""
+void main(
+       float2 t : TEXCOORD0,
+       uniform float2 meas: register(c0),
+       uniform sampler2D t0: TEXUNIT0,
+       out half4 color: COLOR) {
+//    if(tex2D(t0, t).x > 0) discard;
+    half4 ders;
+    ders.xy = ddx(t);
+    ders.zw = ddy(t);
+
+    half2 dx = ders.xy;
+    half2 dy = ders.zw;
+    
+    half4 dersq = ders * ders;
+
+    half2 dersums = dersq.xz + dersq.yw;
+    half l = max(dersums.x, dersums.y);
+    l = sqrt(l);
+    // l = max(length(ddx(t)), length(ddy(t)))
+
+    // * 512 = texture width
+    // / 2 = half, for radius
+    // / 2 = half, for x-sampling pattern
+    half maxrad = l * 512 / 2 / 2 * meas.y;
+
+    half4 c0 = tex2D(t0, t + meas.x*(dx+dy));
+
+
+    half4 c1 = tex2D(t0, t + meas.x*(dx-dy));
+    half4 c2 = tex2D(t0, t + meas.x*(-dx+dy));
+    half4 c3 = tex2D(t0, t + meas.x*(-dx-dy));
+
+    half4 dists = half4(
+       // c0.x + c0.w * 256,
+       c0.w + c0.x * 256,
+       c1.x + c1.w * 256,
+       c2.x + c2.w * 256,
+       c3.x + c3.w * 256);
+
+
+    dists *= 16;
+
+
+    fixed c = dot(dists <= maxrad, fixed4(1,1,1,1)) / 4;
+
+    fixed rgb = (1 - c);
+
+    color.xyz = rgb;
+//    color.y = c0.x - maxrad * 1000;
+ //   color.z = c0.w + maxrad * 1000;
+    color.w = 1;
+
+}
+
+
+""", "fp30")),
 GL.createProgram("""!!FP1.0
+DECLARE meas;
 MOV R10, f[TEX0].xyzw;
 DDX R8, R10;
 DDY R9, R10;
@@ -449,7 +508,7 @@
         parcs = vs.orthoCS(0, "para", 0, 0, 0, 0, 0)
 
 
-       vs.put( GLRen.createProgramLocalParameterARB("FRAGMENT_PROGRAM_ARB", 0),
+       vs.put( GLRen.createProgramNamedParameterNV(fpid, "meas"),
            parcs)
 
        cs = vs.rotateCS(cs, "b", self.a)




reply via email to

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