[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] libvob bench/mark.py include/vob/VecGL.hxx incl...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] libvob bench/mark.py include/vob/VecGL.hxx incl... |
Date: |
Fri, 31 Oct 2003 02:22:11 -0500 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/10/31 02:22:10
Modified files:
bench : mark.py
include/vob : VecGL.hxx
include/vob/vobs: Text.hxx
org/nongnu/libvob/gl: GL.java SimpleAlphaFont.java
vob/demo/aniso : fontscene.py probe2.py
vob/lava/snaps : aniso_fontscene.py aniso_gf4go.py
vob/putil : demokeys.py snapshots.py
Added files:
lava/cad : box.py box2.py
vob/demo/aniso : bigquad.py
vob/lava : normalizedquads.py
Log message:
sync
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/bench/mark.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/VecGL.hxx.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/include/vob/vobs/Text.hxx.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/lava/cad/box.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/lava/cad/box2.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/GL.java.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/aniso/bigquad.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/aniso/fontscene.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/aniso/probe2.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/lava/normalizedquads.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/lava/snaps/aniso_fontscene.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/lava/snaps/aniso_gf4go.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/demokeys.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/putil/snapshots.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/bench/mark.py
diff -u libvob/bench/mark.py:1.11 libvob/bench/mark.py:1.12
--- libvob/bench/mark.py:1.11 Sat Aug 16 05:04:54 2003
+++ libvob/bench/mark.py Fri Oct 31 02:22:08 2003
@@ -74,6 +74,7 @@
vs = win.createVobScene()
sx = vs.size.width
+ outfile = open("benchdata","w")
for ar in _argLists(args):
vs = win.createVobScene()
@@ -88,8 +89,11 @@
# print "Now: ",iters,total,ms
print ou
print ms, "ms with ",iters," in ",total
+ outfile.write("%s %s\n" % (ou, ms))
print 1000.0 / ms,"per second\n"
+ outfile.close()
+
def runPureBench(func, args):
for ar in _argLists(args):
# Precompile for JIT
@@ -99,7 +103,7 @@
total = 0
iters = 1
- while total < 2.0:
+ while total < 3.0:
iters *= 2
(total, str) = func(iters, **ar)
ms = total * 1. / iters * 1000
Index: libvob/include/vob/VecGL.hxx
diff -u libvob/include/vob/VecGL.hxx:1.4 libvob/include/vob/VecGL.hxx:1.5
--- libvob/include/vob/VecGL.hxx:1.4 Fri Jun 27 10:34:23 2003
+++ libvob/include/vob/VecGL.hxx Fri Oct 31 02:22:08 2003
@@ -57,6 +57,13 @@
glTexCoord3f(v.x, v.y, v.z);
}
+ inline void glMultiTexCoord(GLenum tex, const ZVec &v) {
+ glMultiTexCoord3f(tex, v.x, v.y, v.z);
+ }
+ inline void glMultiTexCoord(GLenum tex, const Vec &v) {
+ glMultiTexCoord2f(tex, v.x, v.y);
+ }
+
}
}
Index: libvob/include/vob/vobs/Text.hxx
diff -u libvob/include/vob/vobs/Text.hxx:1.8
libvob/include/vob/vobs/Text.hxx:1.9
--- libvob/include/vob/vobs/Text.hxx:1.8 Sun Sep 28 09:02:17 2003
+++ libvob/include/vob/vobs/Text.hxx Fri Oct 31 02:22:09 2003
@@ -34,9 +34,11 @@
#include <vob/glerr.hxx>
#include <vob/text/QuadFont.hxx>
#include <vob/Types.hxx>
+#include <vob/VecGL.hxx>
namespace Vob {
namespace Vobs {
+ using namespace VecGL;
PREDBGVAR(dbg_text);
@@ -143,6 +145,138 @@
typedef Text1Base<unicodecharvector> Text1;
VOB_DEFINED(Text1);
+
+/** In a triangle with the given vertices, find
+ * the change of t at unit change of v in x or y direction.
+ */
+std::pair<Pt,Pt> texDerivs(Pt v00, Pt v01, Pt v10, Pt t00, Pt t01, Pt t10) {
+ // Now, find out the correct offsets to the texture
+ // coordinates.
+ Pt va = v10-v00; Pt ta = t10-t00;
+ Pt vb = v01-v00; Pt tb = t01-t00;
+
+ if(fabs(vb.x) > fabs(va.x)) {
+ std::swap(va,vb);
+ std::swap(ta,tb);
+ }
+ // va now greater in x dir
+ if(fabs(va.x) < 0.000001) va.x = 1; // avoid inf
+ float mul = - vb.x / va.x;
+ // This should now have zero x coordinate
+ Pt vy = vb + mul*va;
+ if(fabs(vy.y) < 0.000001) vy.y = 1; // avoid inf
+ Pt ty = (tb + mul*ta);
+
+ // Zero y coordinate
+ Pt vx = va - (va.y / vy.y)*vy;
+ Pt tx = ta - (va.y / vy.y)*ty;
+
+ DBG(dbg_text) << "texDerivs calc: "
+ <<va<<vb<<ta<<tb<<mul<<"\n";
+ DBG(dbg_text) << "texDerivs vxy: "
+ <<vx<<vy<<tx<<ty<<"\n";
+
+
+ return std::pair<Pt,Pt>(ty * (1/vy.y),tx * (1/vx.x));
+}
+
+
+/** An implemenentation of text rendering
+ * using 4 texunits for supersampling.
+ * This vob only sets up the texture coordinates.
+ */
+template<class str> struct TextSuper4Base {
+ enum { NTrans = 1 };
+
+
+ Text::QuadFont *font;
+ str text;
+ float yoffs;
+ int flags;
+
+ template<class F> void params(F &f) {
+ f(font, text, yoffs, flags);
+ }
+
+ template<class T> void render(const T &t) const {
+ int curTexInd = -1;
+ int minGlyph = 0; int nGlyphs = font->textureIndex.size();
+ GLERR;
+
+ float x = 0;
+ float y = yoffs;
+ glBegin(GL_QUADS);
+ for (typename str::const_iterator it = text.begin();
+ it != text.end(); ++it) {
+ int glyph = *it;
+ if(glyph < minGlyph || glyph >= nGlyphs)
+ continue;
+ int texInd = font->textureIndex[glyph];
+ if(texInd < 0) continue;
+ if(curTexInd != texInd) {
+ glEnd();
+ GLERR;
+ font->bindTextures(texInd);
+ GLERR;
+ glBegin(GL_QUADS);
+ curTexInd = texInd;
+ }
+ // Won't use font->texCoords since
+ // it depends on the transformation
+
+#define do_corner(ver, tex, a, b) \
+ Pt tex = Pt( \
+ font->coordinates[8*glyph + 4 + a], \
+ font->coordinates[8*glyph + 4 + b]); \
+ ZPt ver = t.transform(ZPt( \
+ x + font->coordinates[8*glyph + 0 + a], \
+ y + font->coordinates[8*glyph + 0 + b], 0));
+
+ do_corner(v00, t00, 0,1);
+ do_corner(v10, t10, 2,1);
+ do_corner(v11, t11, 2,3);
+ do_corner(v01, t01, 0,3);
+#undef do_corner
+
+ std::pair<Pt,Pt> deriv0 = texDerivs(v00,v01,v10, t00,t01,t10);
+
+#define do_vertex(ver, tex) \
+ glMultiTexCoord(GL_TEXTURE0, tex - .25 * deriv0.first - .25*deriv0.second); \
+ glMultiTexCoord(GL_TEXTURE1, tex + .25 * deriv0.first - .25*deriv0.second); \
+ glMultiTexCoord(GL_TEXTURE2, tex - .25 * deriv0.first + .25*deriv0.second); \
+ glMultiTexCoord(GL_TEXTURE3, tex + .25 * deriv0.first + .25*deriv0.second); \
+ glVertex(ver);
+
+ do_vertex(v00, t00);
+ do_vertex(v10, t10);
+ do_vertex(v11, t11);
+ do_vertex(v01, t01);
+
+ DBG(dbg_text)<<"Coords: "<<v00<<v10<<v11<<v01<<"\n";
+ DBG(dbg_text)<<"Tex: "<<t00<<t10<<t11<<t01<<"\n";
+ DBG(dbg_text)<<"derivs: "<<deriv0.first<<deriv0.second<<"\n";
+
+ // Assume the transformation is the same all through the quad.
+ // pair<Pt,Pt> deriv1 = texDerivs(v11,v01,v10, t11,t01,t10);
+
+ x += font->advances[glyph];
+
+
+ }
+ glEnd();
+ font->unbindTextures();
+ GLERR;
+
+ DBG(dbg_text) << "End text render\n";
+
+ }
+
+};
+
+typedef TextSuper4Base<unicodecharvector> TextSuper4;
+
+VOB_DEFINED(TextSuper4);
+
}
}
Index: libvob/org/nongnu/libvob/gl/GL.java
diff -u libvob/org/nongnu/libvob/gl/GL.java:1.28
libvob/org/nongnu/libvob/gl/GL.java:1.29
--- libvob/org/nongnu/libvob/gl/GL.java:1.28 Wed Oct 22 04:57:48 2003
+++ libvob/org/nongnu/libvob/gl/GL.java Fri Oct 31 02:22:09 2003
@@ -903,6 +903,12 @@
/** Add a dependency.
* Adds an object that mustn't get garbage collected
* before this one.
+ * For example, if you use a texture id that you get from
+ * a GL.Texture object's getTexId() method, you should
+ * probably ensure that that texture won't get deleted
+ * before this display list. Calling displayList.addDepend()
+ * with the texture object ensures this as it stores a reference
+ * to the texture in this display list.
*/
public void addDepend(Object o) {
if(depends == null) depends = new ArrayList();
Index: libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java
diff -u libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.4
libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.5
--- libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java:1.4 Wed Oct 22
04:57:48 2003
+++ libvob/org/nongnu/libvob/gl/SimpleAlphaFont.java Fri Oct 31 02:22:09 2003
@@ -85,6 +85,12 @@
return textures;
}
+ static public GLFont convertFont(GL.FTFont ftfont, int border,
+ float xscale, float yscale,
+ String[] texParams) {
+ return convertFont(ftfont, border, xscale, yscale, texParams, 1);
+ }
+
/** Convert a file name to FTFont to a GLFont.
* @param ftfont The FTFont to convert.
* @param border The amount of border (in texels) to add around the
@@ -94,7 +100,7 @@
*/
static public GLFont convertFont(GL.FTFont ftfont, int border,
float xscale, float yscale,
- String[] texParams) {
+ String[] texParams, int ntexunits) {
float height = (ftfont.getHeight() >> 6) * yscale;
float yoffs = (ftfont.getYOffs() >> 6) * yscale;
@@ -111,6 +117,12 @@
Mosaic2D.Tile[] tiles = generateTiles(chars, meas, border);
GL.Texture[] textures = createTextures(tiles, bitmaps, texParams);
+ GL.Texture[] multextures = new GL.Texture[ntexunits * textures.length];
+ for(int i=0; i<textures.length; i++) {
+ for(int j=0; j<ntexunits; j++) {
+ multextures[j + ntexunits*i] = textures[i];
+ }
+ }
for(int i=0; i<chars.length; i++) {
if(tiles[i].w == 0) continue;
@@ -129,11 +141,16 @@
GL.QuadFont quadFont = GL.createQuadFont();
+ String[] texUnits = new String[ntexunits];
+ String[] texTypes = new String[ntexunits];
+ for(int i=0; i<ntexunits; i++) {
+ texUnits[i] = "TEXTURE"+i+"_ARB";
+ texTypes[i] = "TEXTURE_2D";
+ }
+
quadFont.setTextures(
- new String[] { "TEXTURE0_ARB" },
- new String[] { "TEXTURE_2D" },
- new String[] { "TEXTURE0_ARB" },
- textures);
+ texUnits, texTypes, texUnits,
+ multextures);
quadFont.setNGlyphs(chars.length);
@@ -164,6 +181,8 @@
return a;
}
static private byte tobyte(int a) {
+ if(a < 0) return 0;
+ if(a > 255) return -1;
if(a > 127) return (byte)(a - 256);
return (byte)a;
}
@@ -172,17 +191,23 @@
}
static private void shrinkX(byte[] data, int width, int height, int fac) {
- if(fac != 2) throw new Error("!!!");
- for(int i=0; i<data.length / 2; i++)
- data[i] = avg(data[2*i], data[2*i+1]);
+ // Assert power of two!
+ while(fac > 1) {
+ for(int i=0; i<data.length / 2; i++)
+ data[i] = avg(data[2*i], data[2*i+1]);
+ fac /= 2;
+ }
}
static private void shrinkY(byte[] data, int width, int height, int fac) {
- if(fac != 2) throw new Error("!!!");
- for(int y=0; y<height/2; y++) {
- for(int x=0; x<width; x++) {
- data[x+width*y] = avg(data[x+width*(2*y)],
data[x+width*(2*y+1)]);
+ // Assert power of two!
+ while(fac > 1) {
+ for(int y=0; y<height/2; y++) {
+ for(int x=0; x<width; x++) {
+ data[x+width*y] = avg(data[x+width*(2*y)],
data[x+width*(2*y+1)]);
+ }
}
+ fac /= 2;
}
}
@@ -214,6 +239,130 @@
}
}
+ static private void sharpen(byte[] data, byte[] into, int w, int h, float
a, float b) {
+ float c = 1 - 4*a - 4*b;
+ for(int x=1; x<w-1; x++) {
+ for(int y=1; y<h-1; y++) {
+ into[x + y*w] =
+ tobyte((int)(
+ c * toint(data[(x+0) + (y+0)*w]) +
+ a * toint(data[(x+1) + (y+0)*w]) +
+ a * toint(data[(x-1) + (y+0)*w]) +
+ a * toint(data[(x+0) + (y+1)*w]) +
+ a * toint(data[(x+0) + (y-1)*w]) +
+ b * toint(data[(x+1) + (y+1)*w]) +
+ b * toint(data[(x+1) + (y-1)*w]) +
+ b * toint(data[(x-1) + (y+1)*w]) +
+ b * toint(data[(x-1) + (y-1)*w]))) ;
+ }
+ }
+ }
+
+ /** Filter the downsampled texture levels of a given texture
+ * with a sharpening filter.
+ * @param f The font to filter
+ * @param a The coefficient to use for direct s or t neighbour
+ * @param b The coefficient to use for diagonal neighbours
+ */
+ static public void filterDownsampled(GL.QuadFont f, float a, float b,
String[] texParams) {
+ GL.Texture[] textures = f.getTextures();
+ for(int t=0; t<textures.length; t++) {
+ GL.Texture tex = textures[t];
+ tex.setTexParameter("TEXTURE_2D",
+ "GENERATE_MIPMAP_SGIS", "FALSE");
+ int[] widths = new int[20];
+ int[] heights = new int[20];
+ byte[][] bytes = new byte[20][];
+ for(int lod = 0; ; lod++) {
+ widths[lod] = (int)(tex.getLevelParameter(lod,
"TEXTURE_WIDTH")[0]);
+ heights[lod] = (int)(tex.getLevelParameter(lod,
"TEXTURE_HEIGHT")[0]);
+ int width = widths[lod];
+ int height = heights[lod];
+ bytes[lod] = new byte[width * height];
+ tex.getTexImage(lod, "ALPHA", "UNSIGNED_BYTE", bytes[lod]);
+ if(width == 1 && height == 1)
+ break;
+ }
+
+ GL.call("DeleteTextures "+tex.getTexId()+"\n");
+
+ for(int i=0; i<texParams.length; i+=2)
+ tex.setTexParameter("TEXTURE_2D", texParams[i], texParams[i+1]);
+
+ for(int lod = 0; bytes[lod] != null; lod++) {
+ int width = widths[lod];
+ int height = heights[lod];
+ byte[] data = bytes[lod];
+
+ byte[] dataInto = new byte[width * height];
+
+ sharpen(data, dataInto, width, height, a, b);
+
+ tex.texImage2D(lod, "ALPHA", width, height, 0,
+ "ALPHA", "UNSIGNED_BYTE", dataInto);
+
+ tex.getTexImage(lod, "ALPHA", "UNSIGNED_BYTE", data);
+ /*
+ pa("Converted "+a+" "+b+" "+width+" "+height);
+ for(int i=0; i<data.length; i++) {
+ pa("Comp: "+i+" "+data[i]+" "+dataInto[i]);
+ if(data[i] != dataInto[i])
+ throw new Error("?!?!");
+ }
+ */
+
+ }
+ }
+ }
+
+ static public void changeFormat(GL.QuadFont f, String newFormat,
+ String[] texParams) {
+ GL.Texture[] textures = f.getTextures();
+ for(int t=0; t<textures.length; t++) {
+ GL.Texture tex = textures[t];
+ tex.setTexParameter("TEXTURE_2D",
+ "GENERATE_MIPMAP_SGIS", "FALSE");
+ int[] widths = new int[20];
+ int[] heights = new int[20];
+ byte[][] bytes = new byte[20][];
+ for(int lod = 0; ; lod++) {
+ widths[lod] = (int)(tex.getLevelParameter(lod,
"TEXTURE_WIDTH")[0]);
+ heights[lod] = (int)(tex.getLevelParameter(lod,
"TEXTURE_HEIGHT")[0]);
+ int width = widths[lod];
+ int height = heights[lod];
+ bytes[lod] = new byte[width * height];
+ tex.getTexImage(lod, "ALPHA", "UNSIGNED_BYTE", bytes[lod]);
+ if(width == 1 && height == 1)
+ break;
+ }
+
+ GL.call("DeleteTextures "+tex.getTexId()+"\n");
+
+ for(int i=0; i<texParams.length; i+=2)
+ tex.setTexParameter("TEXTURE_2D", texParams[i], texParams[i+1]);
+
+ for(int lod = 0; bytes[lod] != null; lod++) {
+ int width = widths[lod];
+ int height = heights[lod];
+ byte[] data = bytes[lod];
+
+
+ tex.texImage2D(lod, newFormat, width, height, 0,
+ newFormat, "UNSIGNED_BYTE", data);
+
+ /*
+ pa("Converted "+a+" "+b+" "+width+" "+height);
+ for(int i=0; i<data.length; i++) {
+ pa("Comp: "+i+" "+data[i]+" "+dataInto[i]);
+ if(data[i] != dataInto[i])
+ throw new Error("?!?!");
+ }
+ */
+
+ }
+ }
+ }
+
/** Get a DrawPixels gl renderable for drawing the actual texels
* of a given level for a given character using a GL_LUMINANCE mapping.
*/
@@ -241,7 +390,7 @@
byte[] ndata = new byte[w*h];
for(int xi = 0; xi < w; xi ++) {
for(int yi = 0; yi < h; yi ++) {
- ndata[xi + w*yi] = data[x + xi + width * (y + yi)];
+ ndata[xi + w*yi] = data[x + xi + width * (y + (h-1 - yi))];
}
}
GL.ByteVector v = GL.createByteVector(w*h);
Index: libvob/vob/demo/aniso/fontscene.py
diff -u libvob/vob/demo/aniso/fontscene.py:1.1
libvob/vob/demo/aniso/fontscene.py:1.2
--- libvob/vob/demo/aniso/fontscene.py:1.1 Wed Oct 22 04:57:49 2003
+++ libvob/vob/demo/aniso/fontscene.py Fri Oct 31 02:22:09 2003
@@ -10,18 +10,21 @@
# self.anisos = [1, 1.5, 2.0, 3.0]
# self.anisos = [1, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0]
+
+ self.filters = [None, (-.25,-.125)]
+
self.anisos = [1, 2]
- height = self.height = 64
+ height = self.height = 128
# string = "AIOSs"
- string = "S"
+ string = "SP"
self.ftfont = vob.gl.GL.createFTFont(
"/usr/share/fonts/type1/gsfonts/n019003l.pfb",
height, height)
- self.fonts = [[
+ self.fonts = [[[
vob.gl.SimpleAlphaFont.convertFont(
self.ftfont, 30,
1./self.height, 1./self.height,
@@ -31,81 +34,84 @@
"TEXTURE_MAX_ANISOTROPY_EXT",
str(ceil(self.anisos[i]))
])
for i in range(0, len(self.anisos))]
+ for k in range(0, len(self.filters))]
for j in range(0,2)]
+ self.superfont = \
+ vob.gl.SimpleAlphaFont.convertFont(
+ self.ftfont, 30,
+ 1./self.height, 1./self.height,
+ [
+ "TEXTURE_MAG_FILTER", "LINEAR",
+ "TEXTURE_MIN_FILTER", "LINEAR_MIPMAP_LINEAR",
+ "TEXTURE_MAX_ANISOTROPY_EXT", "2"
+ ], 4)
+
# 0: horizontal, 1: vertical
- for i in range(0, len(self.fonts[0])):
- vob.gl.SimpleAlphaFont.postprocessGLFont_reduceReso(
- self.fonts[0][i].getQuadFont(), self.anisos[i], 1)
- for i in range(0, len(self.fonts[1])):
- vob.gl.SimpleAlphaFont.postprocessGLFont_reduceReso(
- self.fonts[1][i].getQuadFont(), 1, self.anisos[i])
-
- if 0:
- self.ftfonts = [
- vob.gl.GL.createFTFont(
- "/usr/share/fonts/type1/gsfonts/n019003l.pfb",
- height, height, int(a * (1<<16)), 0, 0, 1<<16)
- for a in self.anisos]
- self.fonts = [
- vob.gl.SimpleAlphaFont.convertFont(
- self.ftfonts[i],
- 80,
- 1./self.height / self.anisos[i], 1./self.height,
- [
+ for k in range(0, len(self.filters)):
+ for i in range(0, len(self.fonts[0][k])):
+ if self.anisos[i] > 1:
+ vob.gl.SimpleAlphaFont.postprocessGLFont_reduceReso(
+ self.fonts[0][k][i].getQuadFont(), self.anisos[i], 1)
+ if self.filters[k]:
+ vob.gl.SimpleAlphaFont.filterDownsampled(
+ self.fonts[0][k][i].getQuadFont(), self.filters[k][0],
self.filters[k][1],
+ [
"TEXTURE_MAG_FILTER", "LINEAR",
"TEXTURE_MIN_FILTER", "LINEAR_MIPMAP_LINEAR",
"TEXTURE_MAX_ANISOTROPY_EXT",
str(ceil(self.anisos[i]))
])
- for i in range(0, len(self.anisos))]
-
-
- self.vftfonts = [
- vob.gl.GL.createFTFont(
- "/usr/share/fonts/type1/gsfonts/n019003l.pfb",
- height, height, (1<<16), 0, 0, int(a*(1<<16)))
- for a in self.anisos]
- self.vfonts = [
- vob.gl.SimpleAlphaFont.convertFont(
- self.vftfonts[i],
- 80,
- 1./self.height, 1./self.height / self.anisos[i],
- [
+ for i in range(0, len(self.fonts[1][k])):
+ if self.anisos[i] > 1:
+ vob.gl.SimpleAlphaFont.postprocessGLFont_reduceReso(
+ self.fonts[1][k][i].getQuadFont(), 1, self.anisos[i])
+ if self.filters[k]:
+ vob.gl.SimpleAlphaFont.filterDownsampled(
+ self.fonts[1][k][i].getQuadFont(), self.filters[k][0],
self.filters[k][1],
+ [
"TEXTURE_MAG_FILTER", "LINEAR",
"TEXTURE_MIN_FILTER", "LINEAR_MIPMAP_LINEAR",
"TEXTURE_MAX_ANISOTROPY_EXT",
str(ceil(self.anisos[i]))
])
- for i in range(0, len(self.anisos))]
- self.texts = [[
+ self.texts = [[[
vob.gl.GLRen.createText1(f.getQuadFont(),
string, 0, 0)
- for f in fonts] for fonts in self.fonts]
+ for f in fonts2] for fonts2 in fonts] for fonts in self.fonts]
+ self.supertext = \
+ vob.gl.GLRen.createTextSuper4(self.superfont.getQuadFont(),
+ string, 0, 0)
- self.levels = [
+ self.levels = [[
[ [
- vob.gl.SimpleAlphaFont.getLevelDrawPixels(f.getQuadFont(),
83, level)
+ vob.gl.SimpleAlphaFont.getLevelDrawPixels(f.getQuadFont(),
ord(string[0]), level)
for level in range(0,9)]
- for f in fonts
+ for f in fonts2]
+ for fonts2 in fonts
]
for fonts in self.fonts]
self.key = KeyPresses(
self,
ListIndex("aniso", "anisos", 0, "Anisotropy (index of list)", "A",
"a"),
- Toggle("shift", 0, "Shift text", "s"),
+ ListIndex("filter", "filters", 0, "Mipmap filter", "F", "f"),
+ Toggle("shift", 0, "Shift text", "m"),
Toggle("vert", 0, "Aniso vertically", "v"),
+ Toggle("super4", 0, "Supersample", "s"),
SlideLin("lodbias", 0, .1, "LOD bias", "b", "B"),
SlideLin("rotation", 0, 1, "Rotation", ">", "<"),
)
def scene(self, vs):
vs.put( background((1,1,1)))
- print "Aniso:",self.anisos[self.aniso],self.vert
+ print "Aniso:",self.anisos[self.aniso],self.vert,self.filter
- text = self.texts[self.vert][self.aniso]
+ if self.super4:
+ text = self.supertext
+ else:
+ text = self.texts[self.vert][self.filter][self.aniso]
shifted = vs.translateCS(0, "SH", 5 * self.shift, 3 * self.shift)
shifted = vs.rotateCS(shifted, "R", self.rotation)
@@ -120,20 +126,30 @@
""" % locals()))
if 1:
- ni = 13
+ ni = 5
y0 = 20
- for size in (8, 8.1, 9.3, 10.4,12,16):
+ if self.super4:
+ vs.put(getDListNocoords(
+ vob.lava.normalizedquads.super4TexSetupCode() +
+ vob.lava.normalizedquads.super4CombinerCode()))
+ for size in (8, 9.3, 10.4,12,16):
for x in range(0,ni):
for y in range(0, ni):
vs.put(text,
vs.orthoCS(shifted, str((size,x,y,"A")), 0,
- 20 + (1*int(size*1.12)+1./ni) * x,
+ 20 + (1*int(size*1.42)+1./ni) * x,
y0 + 20 + (int(size*1.12)+1./ni) * y,
size, size))
y0 += int(ni * size * 1.2 )
- if 1:
+ if self.super4:
+ vs.put(getDListNocoords(
+ vob.lava.normalizedquads.super4TeardownCode() + """
+ Disable REGISTER_COMBINERS_NV
+ """
+ ))
+ if not self.super4:
for level in range(0,8):
- vs.put(self.levels[self.vert][self.aniso][level],
+
vs.put(self.levels[self.vert][self.filter][self.aniso][level],
vs.orthoCS(0, str(("I",level)), 0,
500, 150 + 70 * level, 1, 1))
if 0:
Index: libvob/vob/demo/aniso/probe2.py
diff -u libvob/vob/demo/aniso/probe2.py:1.1 libvob/vob/demo/aniso/probe2.py:1.2
--- libvob/vob/demo/aniso/probe2.py:1.1 Wed Oct 22 05:00:50 2003
+++ libvob/vob/demo/aniso/probe2.py Fri Oct 31 02:22:09 2003
@@ -60,50 +60,17 @@
"RGBA", "UNSIGNED_BYTE", ebytes)
-quadlist = vob.gl.GL.createDisplayList("""
- Begin QUADS
- TexCoord 0 0
- Vertex 0 0
- TexCoord 0 1
- Vertex 0 1
- TexCoord 1 1
- Vertex 1 1
- TexCoord 1 0
- Vertex 1 0
- End
-""")
+quadlist = vob.lava.normalizedquads.simpleQuadList(0,0,1,1)
quadlistId = quadlist.getDisplayListID()
lc = -1
uc = 2
-triplequadlist = vob.gl.GL.createDisplayList("""
- Begin QUADS
- TexCoord %(lc)s %(lc)s
- Vertex %(lc)s %(lc)s
- TexCoord %(lc)s %(uc)s
- Vertex %(lc)s %(uc)s
- TexCoord %(uc)s %(uc)s
- Vertex %(uc)s %(uc)s
- TexCoord %(uc)s %(lc)s
- Vertex %(uc)s %(lc)s
- End
-""" % locals())
+triplequadlist = vob.lava.normalizedquads.simpleQuadList(lc,lc,uc,uc)
triplequadlistId = triplequadlist.getDisplayListID()
lc = -2
uc = 3
-quintuplequadlist = vob.gl.GL.createDisplayList("""
- Begin QUADS
- TexCoord %(lc)s %(lc)s
- Vertex %(lc)s %(lc)s
- TexCoord %(lc)s %(uc)s
- Vertex %(lc)s %(uc)s
- TexCoord %(uc)s %(uc)s
- Vertex %(uc)s %(uc)s
- TexCoord %(uc)s %(lc)s
- Vertex %(uc)s %(lc)s
- End
-""" % locals())
+quintuplequadlist = vob.lava.normalizedquads.simpleQuadList(lc,lc,uc,uc)
quintuplequadlistId = quintuplequadlist.getDisplayListID()
if fsaaCompatibility:
@@ -111,9 +78,7 @@
quadlistId = triplequadlistId
xoffs = 0
-list = ["""
- BindTexture TEXTURE_2D %s
-""" % tex.getTexId()]
+list = []
sqx = 10
sqy = 100
@@ -149,20 +114,25 @@
color = (1. / (levelSize * levelSize));
if not fsaaCompatibility:
- xoffsflub = xoffs
+ xoffsflub = xoffs
list2.append("""
CopyTexImage2D TEXTURE_2D 0 RGBA8 %(xoffsflub)s %(yingl)s
%(levelSize)s %(levelSize)s 0
""" % locals())
else:
+ # Get the texture properly sized
+ list2.append("""
+ CopyTexImage2D TEXTURE_2D 0 RGBA8 0 0 %(levelSize)s %(levelSize)s 0
+ """ % locals())
# XXX ??? !!! For some reason, the X coordinate is in
# ABSOLUTE SCREEN COORDINATES on NV 44.96 when using Gf4Go FSAA.
# Y coordinate is normal.
# Strange bug, anyone?
- xoffsflub = xoffs - 3
+ flub = -3
for x in range(0, maxsize >> i):
for y in range(0, maxsize >> i):
- xm = xoffsflub + 3 + x*4
- ym = yingl + 3 + y*4
+
+ xm = flub + 2 + (x+xoffs)*4
+ ym = 768 - ( 3 + (levelSize -1 - y)*4 )
list2.append("""
CopyTexSubImage2D TEXTURE_2D 0 %(x)s %(y)s %(xm)s %(ym)s 1 1
""" % locals())
@@ -229,6 +199,7 @@
SlideLog("scale", .09, "isotropic scale", "k", "j"),
SlideLog("aniso", 1, "anisotropy", "l", "h"),
ListIndex("minfilter", "minfilters", 0, "Filter type", "F", "f"),
+ Toggle("super4", 0, "4xSS", "s"),
)
def scene(self, vs):
self.vs = vs
@@ -252,7 +223,7 @@
# Set rotation and scale center to halfway of the texel
texturemat = vs.translateCS(texturemat, "D", -.5, -.5)
- tex.setTexParameter("TEXTURE_2D", "TEXTURE_MAG_FILTER", "LINEAR")
+ tex.setTexParameter("TEXTURE_2D", "TEXTURE_MAG_FILTER", "NEAREST")
tex.setTexParameter("TEXTURE_2D", "TEXTURE_MIN_FILTER",
self.minfilters[self.minfilter])
tex.setTexParameter("TEXTURE_2D", "TEXTURE_MAX_ANISOTROPY_EXT",
self.faniso)
@@ -272,18 +243,32 @@
""")))
if zeroval == 0:
- vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+ if self.super4:
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
- Enable REGISTER_COMBINERS_NV
+ Enable REGISTER_COMBINERS_NV
- # SPARE0 = ( (+TEX0) ) * 2
+ SPARE0 = (TEX0 + TEX1) * 0.5
- SPARE0 = ( (+TEX0) )* 2
+ SPARE1 = (TEX2 + TEX3) * 0.5
- color = SPARE0
- alpha = 1
+ color = SPARE0 + SPARE1
+ alpha = 1
- """)))
+ """)))
+ else:
+ vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
+
+ Enable REGISTER_COMBINERS_NV
+
+ # SPARE0 = ( (+TEX0) ) * 2
+
+ SPARE0 = ( (+TEX0) )* 2
+
+ color = SPARE0
+ alpha = 1
+
+ """)))
else:
vs.put(getDListNocoords(vob.putil.nvcode.parseCombiner("""
@@ -299,7 +284,22 @@
""")))
vs.put(GLRen.createTransMatrix("TEXTURE"),
texturemat)
- vs.put(list)
+
+ if self.super4:
+ vs.put(getDListNocoords(
+ vob.lava.normalizedquads.super4SetupCode(tex)))
+ vs.put(list)
+ vs.put(getDListNocoords(
+ vob.lava.normalizedquads.super4TeardownCode()))
+ else:
+ vs.put(getDListNocoords("""
+ BindTexture TEXTURE_2D %s
+ """ % tex.getTexId()))
+ vs.put(list)
+ vs.put(getDListNocoords("""
+ BindTexture TEXTURE_2D 0
+ """))
+
vs.put(getDListNocoords("""
PopAttrib
"""))
Index: libvob/vob/lava/snaps/aniso_fontscene.py
diff -u libvob/vob/lava/snaps/aniso_fontscene.py:1.1
libvob/vob/lava/snaps/aniso_fontscene.py:1.2
--- libvob/vob/lava/snaps/aniso_fontscene.py:1.1 Wed Oct 22 04:57:49 2003
+++ libvob/vob/lava/snaps/aniso_fontscene.py Fri Oct 31 02:22:10 2003
@@ -27,27 +27,30 @@
from vob.putil.snapshotutil import *
-def run():
- scene = vob.demo.aniso.fontscene.Scene()
+footprint = (19, 32, 67, 99)
+
+def setState(scene):
# Base shot
scene.aniso = 0
scene.shift = 0
scene.vert = 0
scene.lodbias = 0
- footprint = (20, 25, 140, 140)
+
+def run():
+ scene = vob.demo.aniso.fontscene.Scene()
+ setState(scene)
+
def sh(file):
vs = getvs()
scene.scene(vs)
shoot(file, vs, *footprint)
- sh("snaps/aniso-font-trilinear.png")
- scene.lodbias = -1
- sh("snaps/aniso-font-lodbias.png")
- scene.lodbias = 0
-
+ sh("tmpsnaps/aniso-font-trilinear.png")
scene.aniso = 1
- sh("snaps/aniso-font-horiz2.png")
+ sh("tmpsnaps/aniso-font-vert2.png")
scene.vert = 1
- sh("snaps/aniso-font-vert2.png")
+ sh("tmpsnaps/aniso-font-horiz2.png")
+ scene.super4 = 1
+ sh("tmpsnaps/aniso-font-super4.png")
Index: libvob/vob/lava/snaps/aniso_gf4go.py
diff -u libvob/vob/lava/snaps/aniso_gf4go.py:1.1
libvob/vob/lava/snaps/aniso_gf4go.py:1.2
--- libvob/vob/lava/snaps/aniso_gf4go.py:1.1 Wed Oct 22 04:57:49 2003
+++ libvob/vob/lava/snaps/aniso_gf4go.py Fri Oct 31 02:22:10 2003
@@ -1,110 +1,31 @@
-#
-# Copyright (c) 2003, Tuomas J. Lukka
-# This file is part of Libvob.
-#
-# Libvob is free software; you can redistribute it and/or modify it under
-# the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Libvob is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
-# Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General
-# Public License along with Libvob; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-# MA 02111-1307 USA
-#
-
-
-# Screenshots for the aniso article to be taken on gf4go:
-# Example footprints of bilinear, trilinear, anisotropic
-# and too anisotropic footprints, as well as the text quality
-# scene
+# (c) Tuomas J. Lukka
+# To be run using __GL_FSAA_MODE=4
from __future__ import nested_scopes
-
+import vob
+import java
from vob.putil.snapshotutil import *
-def run():
- scene = vob.demo.aniso.probe2.Scene()
-
- scene.rot = 30
- scene.scale = .09
- scene.ctrx=.463
- scene.ctry=.523
+java.lang.System.setProperty("__GL_FSAA_MODE", "4")
+from vob.lava.snaps.aniso_gffx import footprint, setISO, setANISO
- k = 150
- footprint = (700-k, 450-k, 100+2*k, 100+2*k)
- # footprint = (0,0,1024,768)
+def run():
+ scene = vob.demo.aniso.probe2.Scene()
+ setISO(scene)
def sh(file):
vs = getvs()
scene.scene(vs)
shoot(file, vs, *footprint)
-
- # Nearest
- scene.maxlevel = 0
- scene.minfilter = scene.minfilters.index("NEAREST")
-
-
- sh("snaps/aniso-gf4go-nearest.png")
-
- # Bilinear
- scene.maxlevel = 3
- scene.minfilter = scene.minfilters.index("LINEAR_MIPMAP_NEAREST")
-
- sh("snaps/aniso-gf4go-bilinear.png")
-
- # Trilinear
- scene.minfilter = scene.minfilters.index("LINEAR_MIPMAP_LINEAR")
-
- sh("snaps/aniso-gf4go-trilinear.png")
-
- # Anisotropic cs
-
- scene.ctry=.498
- scene.ctrx=.483
- scene.rot = 5
- scene.aniso = 2
-
- # Anisotropic nearest
- scene.minfilter = scene.minfilters.index("NEAREST")
- scene.maxlevel = 0
-
- sh("snaps/aniso-gf4go-aniso-nearest.png")
-
- # Anisotropic trilinear
scene.minfilter = scene.minfilters.index("LINEAR_MIPMAP_LINEAR")
- scene.faniso = 1
- scene.maxlevel = 4
+ scene.maxlevel=2
- sh("snaps/aniso-gf4go-trilinear-aniso.png")
+ sh("tmpsnaps/aniso-gf4go-tbl-iso-fsaa.png")
- # Anisotropic, with aniso filter
- scene.faniso = 10
- scene.maxlevel = 3
-
- sh("snaps/aniso-gf4go-aniso.png")
-
-
-
- # ortho text
- scene = vob.demo.aniso.probe2.Scene()
- scene.faniso = 1
-
- scene.rot = 0
- scene.scale = .09
- scene.ctrx = .51
- scene.ctry = .507
- scene.minfilter = scene.minfilters.index("LINEAR_MIPMAP_LINEAR")
+ setANISO(scene)
+ scene.maxlevel=1
+ scene.faniso=2
+ sh("tmpsnaps/aniso-gf4go-tbl-aniso-fsaa.png")
- sh("snaps/aniso-gf4go-ortho-trilinear.png")
- # Anisotext
- scene.faniso = 2
- scene.aniso = 2
- sh("snaps/aniso-gf4go-ortho-stretchsquish.png")
Index: libvob/vob/putil/demokeys.py
diff -u libvob/vob/putil/demokeys.py:1.5 libvob/vob/putil/demokeys.py:1.6
--- libvob/vob/putil/demokeys.py:1.5 Thu Aug 28 20:00:24 2003
+++ libvob/vob/putil/demokeys.py Fri Oct 31 02:22:10 2003
@@ -30,6 +30,8 @@
# For the compiled regexp class
somere = re.compile("[ab]")
+dbg = 0
+
class KeyPresses:
"""An object that can function as the ``key`` method
of a gl demo.
@@ -41,10 +43,10 @@
self.things = args
self.keymap = {}
self.res = []
- print "KEYMAP: things = ",self.things
+ if dbg: print "KEYMAP: things = ",self.things
for t in self.things:
for k in t.getKeys():
- print "KEY: ",k
+ if dbg: print "KEY: ",k
self.keymap[k[0]] = k[1]
self.res.extend(t.getREs())
t.prepare(scene)
@@ -74,7 +76,7 @@
class _Presses:
def __init__(self, opts, *keys):
- print "PRESSES: ",keys
+ if dbg: print "PRESSES: ",keys
self.keys = keys
if opts.get("noAnimation", 0):
self.keys = [
Index: libvob/vob/putil/snapshots.py
diff -u libvob/vob/putil/snapshots.py:1.1 libvob/vob/putil/snapshots.py:1.2
--- libvob/vob/putil/snapshots.py:1.1 Wed Oct 22 04:57:50 2003
+++ libvob/vob/putil/snapshots.py Fri Oct 31 02:22:10 2003
@@ -87,6 +87,7 @@
class Bindings(vob.AbstractBinder):
def keystroke(self, s):
+ print "KEY: ",s
global keyhit
keyhit = 1
if s == "Ctrl-Q":
@@ -121,6 +122,7 @@
except SnapshotLoop:
print "Continuing"
continue
+ break
else:
loadScenes()
except:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] libvob bench/mark.py include/vob/VecGL.hxx incl...,
Tuomas J. Lukka <=