Code Search for Developers
 
 
  

fpfont.py from gzz at Krugle


Show fpfont.py syntax highlighted

# 
# Copyright (c) 2003, Tuomas J. Lukka and Janne Kujala
# 
# This file is part of Gzz.
# 
# Gzz 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.
# 
# Gzz 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 Gzz; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA  02111-1307  USA
# 
# 

from gfx.util.demokeys import *
from gfx.util.misc import *
from gfx.libpaper.texcache import getCachedTexture
import gzz.media.impl
from gfx.util.fparb import dump


pis = gzz.media.impl.PageImageScroll(None, gzz.mediaserver.Mediaserver.Id(
    "01E1682758ABF63E7833692653A5DE46EA53A6F8AA"))

rect = GLSpans.getRect(pis.getCurrent())

if globals().has_key("fp"):
	for f in fp:
		f.deleteObject()


fp = [GL.createProgram(
"""!!ARBfp1.0

# Sharpen the texture value 

TEMP n1, n2, n3, n4, p;
TEMP sum;

# Read the pixel and its neighbours
TEX p, fragment.texcoord[0].xyxy, texture[0], 2D;
TEX n1, fragment.texcoord[1].xyxy, texture[0], 2D;
TEX n2, fragment.texcoord[2].xyxy, texture[0], 2D;
TEX n3, fragment.texcoord[3].xyxy, texture[0], 2D;
TEX n4, fragment.texcoord[4].xyxy, texture[0], 2D;

# Calculate sum of neighbours

ADD sum, n1, n2;
ADD sum, sum, n3;
ADD sum, sum, n4;

MUL p, p, fragment.texcoord[5].x;
MAD p, sum, fragment.texcoord[5].y, p;

MOV result.color, p;
END
"""
),

GL.createProgram(
"""!!ARBfp1.0

# Sharpen the texture value 

TEMP p, c;

MOV c, fragment.texcoord[0];
MOV c.w, fragment.texcoord[5].w;

# Read the pixel and its neighbours
TXB p, c, texture[0], 2D;

MOV result.color, p;
END
"""),

GL.createProgram(
"""!!ARBfp1.0

# Sharpen the texture value 

TEMP p;

# Read the pixel and its neighbours
TEX p, fragment.texcoord[0], texture[0], 2D;


MUL p.y, p.x, p.x;
MUL p.z, p.x, p.y;
MUL p.x, -.666, p.z;
MAD p.x, 1.666, p.y, p.x;

MOV p.w, 1;
MOV result.color, p.xxxw;
END
"""),

GL.createProgram(
"""!!ARBfp1.0

# Sharpen by extrapolating from a lod-biased blurred tex access.

TEMP p, bp;

TEX p, fragment.texcoord[0].xyxy, texture[0], 2D;
MOV bp, fragment.texcoord[0].xyxy; 
MOV bp.w, fragment.texcoord[5].w;
TXB bp, bp, texture[0], 2D;

MUL p, p, fragment.texcoord[5].x;
MAD p, bp, fragment.texcoord[5].z, p;

SWZ result.color, p,x,y,z,1;

END
"""),
GL.createProgram(
"""!!ARBfp1.0

TEMP p, bp;
MAD p, fragment.texcoord[5].w, fragment.texcoord[5].w, fragment.texcoord[0];
TEX result.color, p, texture[0], 2D;

END
"""),
]

dump(fp[0].getProgId())

class Scene:
    def __init__(self):
	self.prognum_dummylist = [ 0 for x in fp ]
	self.key = KeyPresses(self,
	    SlideLin("x", 0, 30, "x coord", "Left", "Right"),
	    SlideLin("y", 0, 30, "x coord", "Up", "Down"),
	    SlideLin("xg", 0, 30, "x coord", "j", "l"),
	    SlideLin("yg", 0, 30, "x coord", "i", ","),
	    SlideLog("ps", 800, "paper scale", "<", ">"),
	    SlideLin("ang", 0, 	5, "angle", "Prior", "Next"),
	    ListIndex("prognum", "prognum_dummylist", 0, "prog type", "T", "t"),
	    Toggle("texfilt", 1, "texture filtering", "f"),
	)

    def scene(self, vs):
	putnoc(vs, background((.5,.8,.5)))

	rot = vs.rotateCS(0, "r", self.ang)
	d = 1. / self.ps
        csg = vs.affineCS(rot, "g", 0, self.xg, self.yg, 
	    self.ps, 0, 0, self.ps)
	vs.map.put(getDList("""

        ActiveTexture TEXTURE0
        TexGen S TEXTURE_GEN_MODE EYE_LINEAR
        TexGen T TEXTURE_GEN_MODE EYE_LINEAR
        TexGen S EYE_PLANE 1 0 0 0
        TexGen T EYE_PLANE 0 1 0 0
        Enable TEXTURE_GEN_S
        Enable TEXTURE_GEN_T

        ActiveTexture TEXTURE1
        TexGen S TEXTURE_GEN_MODE EYE_LINEAR
        TexGen T TEXTURE_GEN_MODE EYE_LINEAR
        TexGen S EYE_PLANE 1 0 0 %(d)s
        TexGen T EYE_PLANE 0 1 0 0
        Enable TEXTURE_GEN_S
        Enable TEXTURE_GEN_T

        ActiveTexture TEXTURE2
        TexGen S TEXTURE_GEN_MODE EYE_LINEAR
        TexGen T TEXTURE_GEN_MODE EYE_LINEAR
        TexGen S EYE_PLANE 1 0 0 0
        TexGen T EYE_PLANE 0 1 0 %(d)s
        #TexGen S EYE_PLANE 1 0 0 %(d)s
        #TexGen T EYE_PLANE 0 1 0 0
        Enable TEXTURE_GEN_S
        Enable TEXTURE_GEN_T

        ActiveTexture TEXTURE3
        TexGen S TEXTURE_GEN_MODE EYE_LINEAR
        TexGen T TEXTURE_GEN_MODE EYE_LINEAR
        TexGen S EYE_PLANE 1 0 0 -%(d)s
        TexGen T EYE_PLANE 0 1 0 0
        Enable TEXTURE_GEN_S
        Enable TEXTURE_GEN_T

        ActiveTexture TEXTURE4
        TexGen S TEXTURE_GEN_MODE EYE_LINEAR
        TexGen T TEXTURE_GEN_MODE EYE_LINEAR
        TexGen S EYE_PLANE 1 0 0 0
	TexGen T EYE_PLANE 0 1 0 -%(d)s
        #TexGen S EYE_PLANE 1 0 0 -%(d)s
        #TexGen T EYE_PLANE 0 1 0 0
        Enable TEXTURE_GEN_S
        Enable TEXTURE_GEN_T

        ActiveTexture TEXTURE0

	""" % locals()), csg)

        cs1 = vs.affineCS(rot, "1", 0, self.x, self.y, 
	    600, 0, 0, 600)

	if self.texfilt:
		minfilt	= "LINEAR_MIPMAP_LINEAR"
		magfilt = "LINEAR"
	else:
		minfilt = "NEAREST_MIPMAP_NEAREST"
		magfilt = "NEAREST"

	texid = rect.texId
	fpid =	fp[self.prognum].getProgId()

        vs.map.put(getDList("""
        BindProgramARB FRAGMENT_PROGRAM_ARB %(fpid)s
	Enable FRAGMENT_PROGRAM_ARB
        
	BindTexture TEXTURE_2D %(texid)s
	TexParameter TEXTURE_2D TEXTURE_MIN_FILTER %(minfilt)s
	TexParameter TEXTURE_2D TEXTURE_MAG_FILTER %(magfilt)s

	Enable TEXTURE_2D
        Color 1 1 1
        Begin QUAD_STRIP
	MultiTexCoord TEXTURE5 4 -.75 -3 -1
        Vertex 0 0
	MultiTexCoord TEXTURE5 4 -.75 -3 1
        Vertex 0 1
	MultiTexCoord TEXTURE5 1 0 0 -1
        Vertex 1 0
	MultiTexCoord TEXTURE5 1 0 0 1
        Vertex 1 1
        End
        Disable FRAGMENT_PROGRAM_ARB
        """ % locals()), cs1)

	print self.prognum


currentScene = Scene()







See more files for this project here

gzz

An implementation of Ted Nelson's ZZstructure. ZZstructure is a new type of programming platform for structured data.

Project homepage: http://savannah.nongnu.org/projects/gzz
Programming language(s): C++,Java,Python
License: lgpl21

  color/
    colors.py
  fillet/
    __init__.py
    ambiguity.py
    oldcode.py
    util.py
    zbuffer.py
  nic/
    README
    stencil.py
    stencildepth.py
  opengl/
    __init__.py
    bumpy.py
    culltest.py
    fragprog.py
    glinfo.py
    imaging.py
    mipmap.py
    pacman.py
    readpixels.py
    stencil.py
    texform.py
    texperf.py
  paper/
    __init__.py
    basis.py
    combinerflow.py
    combiners.py
    combinerutil.py
    multipaper.py
    singlepaper.py
    util.py
  Makefile
  __init__.py
  brokentext.py
  buoydev.py
  buoyoing.py
  calendarvobtest.py
  clamptexture.cxx
  clonetest.py
  coords_benchmark.py
  debugtest.cxx
  fillets.py
  fisheye.py
  fontfilter.py
  fontfilter2.py
  fpfont.py
  frametest.cxx
  irregu3.py
  irregu4.py
  irreguellipse.py
  irregular2.py
  irregularframe.py
  keymap-test.py
  memoryleak.py
  mipzip.py
  motion.py
  ovalvobtest.py
  pagespan.py
  projectivecoords.py
  psyko.py
  psyko2.py
  softshadow.py
  sqfillet.py
  testtimeout.py
  texlab.py
  text.py
  text_benchmark.py
  texturelab.py
  tubeframe.cxx
  tubeframe.hxx
  viewtest.py
  vpbuoy.py
  xuconn.py
  xupdf.py
  zipf.py