gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] libvob/org/nongnu/libvob demo/fpfont.py gl/GL.java


From: Tuomas J. Lukka
Subject: [Gzz-commits] libvob/org/nongnu/libvob demo/fpfont.py gl/GL.java
Date: Wed, 09 Apr 2003 06:54:23 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Changes by:     Tuomas J. Lukka <address@hidden>        03/04/09 06:54:22

Modified files:
        org/nongnu/libvob/demo: fpfont.py 
        org/nongnu/libvob/gl: GL.java 

Log message:
        Distfilter

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/demo/fpfont.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: libvob/org/nongnu/libvob/demo/fpfont.py
diff -u libvob/org/nongnu/libvob/demo/fpfont.py:1.5 
libvob/org/nongnu/libvob/demo/fpfont.py:1.6
--- libvob/org/nongnu/libvob/demo/fpfont.py:1.5 Tue Apr  8 16:25:02 2003
+++ libvob/org/nongnu/libvob/demo/fpfont.py     Wed Apr  9 06:54:22 2003
@@ -7,6 +7,67 @@
 
 from math import sin
 import math
+import jarray
+
+if not hasattr(vob.putil.demowindow, "font"):
+
+    font = GL.createFont(None, 64)
+    vob.putil.demowindow.font = font
+    fonttexs = []
+
+    fn = jarray.zeros(10*10, 'b')
+    fn2 = jarray.zeros(10*10, 'h')
+
+    fn[15] = 1
+    for i in range(0,20): # exercise JVM
+       print "Exercise ",i
+       vob.util.TexManip.minDist(fn, fn2, 10, 10, 10)
+
+       for y in range(0,10):
+           print " ".join([str(fn2[10*y + i]) for i in range(0,10)])
+
+
+    print "Tex: ", font.getNTextures();
+    for i in range(0, font.getNTextures()):
+       t = font.getTexture(i)
+       vob.putil.texture.printTex(t.getTexId())
+       w = int(t.getLevelParameter(0, "TEXTURE_WIDTH")[0])
+       h = int(t.getLevelParameter(0, "TEXTURE_HEIGHT")[0])
+       print "T",i,t,w,h
+
+       fn = jarray.zeros(2*w*h, 'b')
+       fn2 = jarray.zeros(w*h, 'h')
+
+       t.getTexImage(0, "ALPHA", "UNSIGNED_BYTE", fn)
+    #    for i in range(0, w*h, 5):
+    #  fn[i] += int(20 * sin(i))
+
+    #    for x in range(0,w,20):
+    #  for y in range(0,w,20):
+    #      print fn[x + w*y]
+       
+       # Distance * 16
+       vob.util.TexManip.minDist(fn, fn2, w, h, 16)
+       print "Maniped1"
+       vob.util.TexManip.b2s(fn2, fn)
+
+       print "Maniped"
+
+    #    for x in range(0,w,20):
+    #  for y in range(0,w,20):
+    #      print fn[x + w*y]
+       
+       t.setTexParameter("TEXTURE_2D", "GENERATE_MIPMAP_SGIS", "TRUE");
+
+       t.texImage2D(0, "LUMINANCE_ALPHA", w, h, 0, "LUMINANCE_ALPHA", 
"UNSIGNED_BYTE", fn)
+
+       fonttexs.append(t)
+
+else:
+    font = vob.putil.demowindow.font
+    for i in range(0, font.getNTextures()):
+       t = font.getTexture(i)
+       t.setTexParameter("TEXTURE_2D", "TEXTURE_MIN_FILTER", "NEAREST");
 
 from org.nongnu.libvob.paper.texcache import getCachedTexture
 
@@ -23,12 +84,42 @@
 
 tex = getCachedTexture(args[7])
 
+# 16 * texel [1/512]
 
 fp = [
 GL.createProgram("""!!FP1.0
 MOV R10, f[TEX0].xyzw;
 DDX R8, R10;
 DDY R9, R10;
+
+DP4 R6, R8.xyxy, R8.xyxy;
+DP4 R7, R9.xyxy, R9.xyxy;
+ADD R6, R6, R7;
+RSQ R6, R6.x;
+
+RCP R6, R6.x;
+MUL R6, R6, 512;
+
+TEX R0, f[TEX0].xyzw, TEX0, 2D;
+# MAD R0, R0.w, 256, R0.x;
+MAD R0, R0.x, 256, R0.w;
+
+# Scale
+MUL R0, R0, .0625;
+MUL R0, R0, 256;
+
+MUL R6, R6, .5;
+
+SLT R0, R0, R6;
+
+MOV R0.xyz, 0;
+MOV o[COLR], R0;
+
+END"""),
+GL.createProgram("""!!FP1.0
+MOV R10, f[TEX0].xyzw;
+DDX R8, R10;
+DDY R9, R10;
 MUL R18, R8, 1;
 MUL R19, R9, 1;
 
@@ -227,9 +318,9 @@
            Enable ALPHA_TEST
            AlphaFunc GREATER 0.99
        """))
-       tx = vob.vobs.TextVob(vob.GraphicsAPI.getInstance().getTextStyle(
-                       "serif", 1, 64),
-                           "address@hidden", 0, None)
+       #tx = vob.vobs.TextVob(vob.GraphicsAPI.getInstance().getTextStyle(
+       #               "serif", 1, 64),
+       #                   "address@hidden", 0, None)
        for x in range(-10,11):
            for y in range(-10,11):
                d = 1 - math.hypot(x,y) / 20
@@ -276,10 +367,14 @@
         cs = vs.orthoCS(0, "a", 0, self.x, self.y, 1, 1)
 
        cs = vs.rotateCS(cs, "b", self.a)
-        
-       for i in range(7,15):
-           csi = vs.orthoCS(cs, str(i), 0, 0, i*(i+1), i, i)
-            putText(vs, csi, " ".join(words[0:3]))
+
+       tx = vob.gl.GLRen.createText1(font, "address@hidden", 0, 0)
+
+       y = 0
+       for i in range(7,20,2):
+           y += i*1.5
+           csi = vs.orthoCS(cs, str(i), 0, 0, y, 2*i, 2*i)
+            vs.put(tx, csi)
         
         putnoc(vs, getDListNocoords("PopAttrib"))
 
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.9 
libvob/org/nongnu/libvob/gl/GL.java:1.10
--- libvob/org/nongnu/libvob/gl/GL.java:1.9     Tue Apr  8 16:25:02 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Wed Apr  9 06:54:22 2003
@@ -335,10 +335,19 @@
      */
     static public class Texture extends NonRenderableJavaObject {
        boolean delReal;
+       /** Create a texture object whose GL texture will not be deleted
+        * upon the deletion of the Java object.
+        */
        private Texture(int id) { super(id); delReal = false; }
+       /** Create a texture object whose GL texture may be deleted
+        * upon the deletion of the Java object.
+        * @param delReal If true, delete the OpenGL texture
+        */
        private Texture(int id, boolean delReal) { super(id); 
            this.delReal = delReal; }
-       protected void deleteObj() { impl_deleteTexture(getId()); }
+       protected void deleteObj() { 
+           if(delReal) impl_deleteTexture(getId()); 
+       }
 
        /** Get the OpenGL texture id of this texture.
         */




reply via email to

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