[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz gfx/demo/text.py gfx/libtext/Text.cxx gzz/v...
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] gzz gfx/demo/text.py gfx/libtext/Text.cxx gzz/v... |
Date: |
Mon, 07 Oct 2002 13:47:55 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Tuomas J. Lukka <address@hidden> 02/10/07 13:47:55
Modified files:
gfx/demo : text.py
gfx/libtext : Text.cxx
gzz/vob : GLTextStyle.java TextVob.java
Log message:
Improve font rendering remarkably: simply multiply the texture-mapped
alpha value; this reduces artifacts considerably.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/text.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtext/Text.cxx.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/GLTextStyle.java.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/vob/TextVob.java.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/text.py
diff -c gzz/gfx/demo/text.py:1.1 gzz/gfx/demo/text.py:1.2
*** gzz/gfx/demo/text.py:1.1 Mon Oct 7 10:18:51 2002
--- gzz/gfx/demo/text.py Mon Oct 7 13:47:55 2002
***************
*** 1,15 ****
fonts = [ GL.createFont("gfx/fonts/a010013l.pfb", size)
for size in (8, 16, 24, 32, 64) ]
A = [GLRen.createHorizText2(f, "ABCgabcg", 1, 1, 1, 0) for f in fonts]
class TextScene:
def __init__(self):
! self.fontind = 0
self.offset = [(0,0),(1.5,1.5),(0,1.5),(1.5,0)]
def key(self, key):
if key == "+":
self.fontind += 1
AbstractUpdateManager.setNoAnimation()
--- 1,25 ----
+ from gfx.libutil import nvcode
+ from gzz.vob import *
fonts = [ GL.createFont("gfx/fonts/a010013l.pfb", size)
for size in (8, 16, 24, 32, 64) ]
+ textstyle = GLTextStyle.create("sans", 0, 1)
+
A = [GLRen.createHorizText2(f, "ABCgabcg", 1, 1, 1, 0) for f in fonts]
+ B = [TextVob(textstyle, "ABCgabcg") for f in fonts]
class TextScene:
def __init__(self):
! self.fontind = len(A)-1
self.offset = [(0,0),(1.5,1.5),(0,1.5),(1.5,0)]
+ self.regcomb = 0
def key(self, key):
+ if key == "c":
+ self.regcomb = not self.regcomb
+ AbstractUpdateManager.setNoAnimation()
+ AbstractUpdateManager.chg()
if key == "+":
self.fontind += 1
AbstractUpdateManager.setNoAnimation()
***************
*** 30,48 ****
Enable BLEND
Disable ALPHA_TEST
Color 0 0 0
! PushAttrib ENABLE_BIT
"""))
y = 20
! for s in (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100):
y += s
for i in (self.fontind,): # range(0,len(A)):
! vs.put(A[i], str((s,i)), 0 + self.offset[0][0], 150 +
self.offset[0][1], y, s, s)
vs.map.put(getDListNocoords("""
PopAttrib
"""))
currentScene = TextScene()
--- 40,83 ----
Enable BLEND
Disable ALPHA_TEST
Color 0 0 0
! PushAttrib ENABLE_BIT TEXTURE_BIT
"""))
+ if self.regcomb:
+ vs.map.put(getDListNocoords(nvcode.combinercode("""
+ Enable REGISTER_COMBINERS_NV
+ CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
+ CombinerParameterNV CONSTANT_COLOR0_NV 0 0 0 0.4
+ CI0 ALPHA A TEXTURE0 UNSIGNED_IDENTITY_NV ALPHA
+ CI0 ALPHA B CONSTANT_COLOR0_NV UNSIGNED_IDENTITY_NV ALPHA
+ CO0 ALPHA SPARE0_NV DISCARD_NV DISCARD_NV SCALE_BY_FOUR_NV
NONE FALSE FALSE FALSE
+
+ FCI A ZERO UNSIGNED_IDENTITY_NV RGB
+ FCI B ZERO UNSIGNED_IDENTITY_NV RGB
+ FCI C ZERO UNSIGNED_IDENTITY_NV RGB
+ FCI D ZERO UNSIGNED_IDENTITY_NV RGB
+
+ FCI G SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA
+ """)))
y = 20
! sizes = (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100, 200)
! for s in sizes:
y += s
for i in (self.fontind,): # range(0,len(A)):
! vs.put(A[i], str((s,i)), 0, 150 + self.offset[0][0], y +
self.offset[0][1], s, s)
vs.map.put(getDListNocoords("""
PopAttrib
"""))
+
+
+ y = 20
+ sizes = (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100, 200)
+ for s in sizes:
+ y += s
+ for i in (self.fontind,): # range(0,len(A)):
+ vs.put(B[i], "B"+str((s,i)), 0, 500 + self.offset[0][0], y +
self.offset[0][1], s, s)
currentScene = TextScene()
Index: gzz/gfx/libtext/Text.cxx
diff -c gzz/gfx/libtext/Text.cxx:1.5 gzz/gfx/libtext/Text.cxx:1.6
*** gzz/gfx/libtext/Text.cxx:1.5 Sun Oct 6 13:37:46 2002
--- gzz/gfx/libtext/Text.cxx Mon Oct 7 13:47:55 2002
***************
*** 59,64 ****
--- 59,65 ----
vector<GLubyte>(
bitmap->buffer, bitmap->buffer + bitmap->width * bitmap->rows)
));
+
}
int FTFont::getLineHeight() {
Index: gzz/gzz/vob/GLTextStyle.java
diff -c gzz/gzz/vob/GLTextStyle.java:1.13 gzz/gzz/vob/GLTextStyle.java:1.14
*** gzz/gzz/vob/GLTextStyle.java:1.13 Sun Oct 6 11:08:02 2002
--- gzz/gzz/vob/GLTextStyle.java Mon Oct 7 13:47:55 2002
***************
*** 33,39 ****
* it's much better to use GraphicsAPI.getTextStyle.
*/
public class GLTextStyle extends TextStyle {
! public static final String rcsid = "$Id: GLTextStyle.java,v 1.13 2002/10/06
15:08:02 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
--- 33,39 ----
* it's much better to use GraphicsAPI.getTextStyle.
*/
public class GLTextStyle extends TextStyle {
! public static final String rcsid = "$Id: GLTextStyle.java,v 1.14 2002/10/07
17:47:55 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
***************
*** 47,54 ****
GLTextStyle s = instances[size];
if(s == null) {
if(theStaticFont == null)
! theStaticFont = GL.createFont("gfx/fonts/a010013l.pfb", 16);
! s = new GLTextStyle(theStaticFont, size / (float)16);
instances[size] = s;
}
return s;
--- 47,54 ----
GLTextStyle s = instances[size];
if(s == null) {
if(theStaticFont == null)
! theStaticFont = GL.createFont("gfx/fonts/a010013l.pfb", 64);
! s = new GLTextStyle(theStaticFont, 1);
instances[size] = s;
}
return s;
Index: gzz/gzz/vob/TextVob.java
diff -c gzz/gzz/vob/TextVob.java:1.36 gzz/gzz/vob/TextVob.java:1.37
*** gzz/gzz/vob/TextVob.java:1.36 Mon Oct 7 13:27:02 2002
--- gzz/gzz/vob/TextVob.java Mon Oct 7 13:47:55 2002
***************
*** 21,27 ****
* Written by Benja Fallenstein and Tuomas Lukka
*/
package gzz.vob;
! import gzz.gfx.gl.GLRen;
import java.awt.Rectangle;
import java.awt.Shape;
import gzz.client.*;
--- 21,27 ----
* Written by Benja Fallenstein and Tuomas Lukka
*/
package gzz.vob;
! import gzz.gfx.gl.*;
import java.awt.Rectangle;
import java.awt.Shape;
import gzz.client.*;
***************
*** 31,37 ****
* from these and use a LineBreaker.
*/
public class TextVob extends HBox.VobHBox {
! String rcsid = "$Id: TextVob.java,v 1.36 2002/10/07 17:27:02 benja Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
--- 31,37 ----
* from these and use a LineBreaker.
*/
public class TextVob extends HBox.VobHBox {
! String rcsid = "$Id: TextVob.java,v 1.37 2002/10/07 17:47:55 tjl Exp $";
public static boolean dbg = false;
private static void pa(String s) { System.err.println(s); }
***************
*** 48,54 ****
super();
this.style = style;
this.text = text;
! this.scale = -1;
}
public TextVob(TextStyle style, float scale, String text) {
--- 48,54 ----
super();
this.style = style;
this.text = text;
! this.scale = 1;
}
public TextVob(TextStyle style, float scale, String text) {
***************
*** 108,118 ****
g.setClip(oldClip);
}
/** The OpenGL renderable for this TextVob.
*/
private GLRen.HorizText2 ht;
- static Vob cl; // Color callList - XXX Should be removed -
- // color should come from outside.
public int addToListGL(GraphicsAPI.Window win,
int[] list, int curs, int coordsys1,
int coordsys2) {
--- 108,146 ----
g.setClip(oldClip);
}
+ static private Vob start, stop;
+ static public Vob getStartCode() {
+ if(start == null) {
+ start = GLCache.getCallList(
+ " PushAttrib ENABLE_BIT TEXTURE_BIT \n"+
+ " Enable REGISTER_COMBINERS_NV \n" +
+ " CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
\n" +
+ " CombinerParameterNV CONSTANT_COLOR0_NV 0 0 0 0.4
\n" +
+ " CombinerInputNV COMBINER0_NV ALPHA VARIABLE_A_NV TEXTURE0
UNSIGNED_IDENTITY_NV ALPHA \n" +
+ " CombinerInputNV COMBINER0_NV ALPHA VARIABLE_B_NV CONSTANT_COLOR0_NV
UNSIGNED_IDENTITY_NV ALPHA \n" +
+ " CombinerOutputNV COMBINER0_NV ALPHA SPARE0_NV DISCARD_NV DISCARD_NV
SCALE_BY_FOUR_NV NONE FALSE FALSE FALSE \n" +
+ " \n" +
+ " FinalCombinerInputNV VARIABLE_A_NV ZERO UNSIGNED_IDENTITY_NV RGB
\n" +
+ " FinalCombinerInputNV VARIABLE_B_NV ZERO UNSIGNED_IDENTITY_NV RGB
\n" +
+ " FinalCombinerInputNV VARIABLE_C_NV ZERO UNSIGNED_IDENTITY_NV RGB
\n" +
+ " FinalCombinerInputNV VARIABLE_D_NV PRIMARY_COLOR_NV
UNSIGNED_IDENTITY_NV RGB \n" +
+ " \n" +
+ " FinalCombinerInputNV VARIABLE_G_NV SPARE0_NV UNSIGNED_IDENTITY_NV
ALPHA \n" +
+ "");
+ }
+ return start;
+ }
+ static public Vob getStopCode() {
+ if(stop == null) {
+ stop = GLCache.getCallList("PopAttrib");
+ }
+ return stop;
+ }
+
+
/** The OpenGL renderable for this TextVob.
*/
private GLRen.HorizText2 ht;
public int addToListGL(GraphicsAPI.Window win,
int[] list, int curs, int coordsys1,
int coordsys2) {
***************
*** 124,134 ****
text, gls.theFont.getHeight(), gls.theFont.getYOffs(),
scale * gls.fontScale, 0);
}
! if(cl == null) {
! cl = GLRen.createCallList("Color 0 0 0 1");
! }
! curs = cl.addToListGL(win, list, curs, coordsys1, 0);
curs = ht.addToListGL(win, list, curs, coordsys1, coordsys2);
return curs;
}
--- 152,160 ----
text, gls.theFont.getHeight(), gls.theFont.getYOffs(),
scale * gls.fontScale, 0);
}
! curs = getStartCode().addToListGL(win, list, curs, 0, 0);
curs = ht.addToListGL(win, list, curs, coordsys1, coordsys2);
+ curs = getStopCode().addToListGL(win, list, curs, 0, 0);
return curs;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz gfx/demo/text.py gfx/libtext/Text.cxx gzz/v...,
Tuomas J. Lukka <=