[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx demo/fontfilter.py libpaper/papermill.p...
From: |
Janne V. Kujala |
Subject: |
[Gzz-commits] gzz/gfx demo/fontfilter.py libpaper/papermill.p... |
Date: |
Fri, 31 Jan 2003 07:09:52 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Janne V. Kujala <address@hidden> 03/01/31 07:09:50
Modified files:
gfx/demo : fontfilter.py
gfx/libpaper : papermill.py texcomb_NV1X.py texops_NV2X.py
texops_STD.py textures.py
gfx/libutil : nvcode.py
Log message:
clean up texparameter handling and enable fp emulation of combiners in
libpaper
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/fontfilter.py.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.70&tr2=1.71&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/texcomb_NV1X.py.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/texops_NV2X.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/texops_STD.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/textures.py.diff?tr1=1.42&tr2=1.43&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libutil/nvcode.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
Patches:
Index: gzz/gfx/demo/fontfilter.py
diff -u gzz/gfx/demo/fontfilter.py:1.13 gzz/gfx/demo/fontfilter.py:1.14
--- gzz/gfx/demo/fontfilter.py:1.13 Thu Jan 30 14:18:56 2003
+++ gzz/gfx/demo/fontfilter.py Fri Jan 31 07:09:49 2003
@@ -17,7 +17,7 @@
print self.bias, self.sharpness
def __init__(self):
- self.tex2 = GL.hasExtension("GL_NV_register_combiners2")
+ self.tex2 = GL.hasExtension("GL_NV_register_combiners2") or
GL.hasExtension("GL_ARB_fragment_program")
self.textscales = [ 2, 4, 0 ]
self.key = KeyPresses(self,
@@ -101,7 +101,7 @@
BindTexture TEXTURE_2D %(texid)s
Enable TEXTURE_2D
- TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS %(bias)s
+ #TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS %(bias)s
"""
if self.tex2:
@@ -116,14 +116,16 @@
BindTexture TEXTURE_2D %(texid)s
Enable TEXTURE_2D
- TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS %(bias2)s
+ #TexEnv TEXTURE_FILTER_CONTROL TEXTURE_LOD_BIAS %(bias2)s
"""
code += """
ActiveTexture TEXTURE0
"""
- vs.map.put(getDList(code % locals()), csg)
+ code = code % locals()
+ print code
+ vs.map.put(getDList(code), csg)
Index: gzz/gfx/libpaper/papermill.py
diff -u gzz/gfx/libpaper/papermill.py:1.70 gzz/gfx/libpaper/papermill.py:1.71
--- gzz/gfx/libpaper/papermill.py:1.70 Mon Jan 27 12:26:04 2003
+++ gzz/gfx/libpaper/papermill.py Fri Jan 31 07:09:49 2003
@@ -49,10 +49,8 @@
# Check whether anisotropic filtering is supported
if GL.hasExtension("GL_EXT_texture_filter_anisotropic"):
- maxaniso = 2.0
- if dbg: print "Using anisotropic filtering with maximum degree", maxaniso
+ if dbg: print "Anisotropic filtering available"
else:
- maxaniso = None
if dbg: print "Anisotropic filtering not available"
@@ -224,10 +222,13 @@
def selectCombiner(self):
# Check which combiners to use.
- if not self.paperopts.use_opengl_1_1 and
GL.hasExtension("GL_NV_register_combiners"):
+ if not self.paperopts.use_opengl_1_1 and (
+ GL.hasExtension("GL_NV_register_combiners") or
+ GL.hasExtension("GL_ARB_fragment_program")):
+
# We have at least a NV10, possibly better.
# Check the number of general combiners to be sure.
- maxcomb = GL.getGLFloat("MAX_GENERAL_COMBINERS_NV")[0]
+ #maxcomb = GL.getGLFloat("MAX_GENERAL_COMBINERS_NV")[0]
#if maxcomb < 4:
if 1: #XXX NV20 version is broken
# use NV10 version
@@ -256,9 +257,9 @@
seed = reg.get(regseed, "seed")
rnd = java.util.Random(seed)
if emboss:
- sh = makeEmbossShaderPass(maxaniso)
+ sh = makeEmbossShaderPass()
else:
- sh = makeNormalShaderPass(maxaniso)
+ sh = makeNormalShaderPass()
types = sh.getTextureTypes()
for i in range(0, len(types)):
@@ -351,7 +352,7 @@
ppass.putNormalTexGen(i, data)
-# not fully used currently
+
class OpenGL11_PaperOptions:
def __init__(self):
self.useOpengL11 = None
@@ -360,7 +361,8 @@
self.lastState = None
# Check which combiners to use.
- if GL.hasExtension("GL_NV_register_combiners"):
+ if (GL.hasExtension("GL_NV_register_combiners") or
+ GL.hasExtension("GL_ARB_fragment_program")):
self.trueOpenGL11 = 0
self.useOpenGL11 = 0
else:
Index: gzz/gfx/libpaper/texcomb_NV1X.py
diff -u gzz/gfx/libpaper/texcomb_NV1X.py:1.23
gzz/gfx/libpaper/texcomb_NV1X.py:1.24
--- gzz/gfx/libpaper/texcomb_NV1X.py:1.23 Mon Oct 14 06:22:27 2002
+++ gzz/gfx/libpaper/texcomb_NV1X.py Fri Jan 31 07:09:49 2003
@@ -5,6 +5,8 @@
from gfx.libcolor.spaces import RGBtoLAB
+from gzz.gfx.gl import GL
+
from math import exp
class TransparentCombinerPass:
@@ -215,6 +217,10 @@
c = (constantcode + c) % locals()
c = nvcode.combinercode(c)
# print "c: ",c
+
+ if not GL.hasExtension("GL_NV_register_combiners"):
+ # Kluge: emulate using fragment program
+ c = nvcode.convCombiner(c, GL)
return c
Index: gzz/gfx/libpaper/texops_NV2X.py
diff -u gzz/gfx/libpaper/texops_NV2X.py:1.10
gzz/gfx/libpaper/texops_NV2X.py:1.11
--- gzz/gfx/libpaper/texops_NV2X.py:1.10 Wed Oct 16 11:23:50 2002
+++ gzz/gfx/libpaper/texops_NV2X.py Fri Jan 31 07:09:49 2003
@@ -94,10 +94,9 @@
pass
class ShaderPass:
- def __init__(self, shaderType, maxaniso):
+ def __init__(self, shaderType):
self.st = shaderType
self.tex = [None for texunit in shaderType]
- self.maxaniso = maxaniso
def getTextureTypes(self):
"Get the texture type names (D2, R2 ...) for the texture units."
return [texunit[1] for texunit in self.st]
@@ -123,17 +122,10 @@
if target != None:
texid = self.tex[t].getTexId()
- minfilter = self.tex[t].minfilter
- magfilter = self.tex[t].magfilter
if texid == None: raise NoTextureSetForStage()
c += """
Enable %(target)s
BindTexture %(target)s %(texid)s
-
- TexParameter %(target)s TEXTURE_WRAP_S REPEAT
- TexParameter %(target)s TEXTURE_WRAP_T REPEAT
- TexParameter %(target)s TEXTURE_MIN_FILTER %(minfilter)s
- TexParameter %(target)s TEXTURE_MAG_FILTER %(magfilter)s
""" % locals()
if len(self.st[t]) > 2: # Previous texture input
c += """
@@ -150,13 +142,6 @@
TexEnv TEXTURE_SHADER_NV OFFSET_TEXTURE_MATRIX_NV %s %s %s
%s
""" % mat
-
- if self.maxaniso != None:
- maxaniso = self.maxaniso
- c += """
- TexParameter %(target)s TEXTURE_MAX_ANISOTROPY_EXT %(maxaniso)s
- """ % locals()
-
return c
def getRGBoutputs(self):
"""A list of the texture units whose outputs are useful in
@@ -168,7 +153,7 @@
def getRGBoutputscales(self):
return [self.tex[i].scale for i in self.getRGBoutputs()]
-def makeNormalShaderPass(maxaniso = None):
- return ShaderPass(shaderTypes[5], maxaniso)
+def makeNormalShaderPass():
+ return ShaderPass(shaderTypes[5])
scaleFactor = 1.5
Index: gzz/gfx/libpaper/texops_STD.py
diff -u gzz/gfx/libpaper/texops_STD.py:1.7 gzz/gfx/libpaper/texops_STD.py:1.8
--- gzz/gfx/libpaper/texops_STD.py:1.7 Wed Oct 16 05:14:10 2002
+++ gzz/gfx/libpaper/texops_STD.py Fri Jan 31 07:09:49 2003
@@ -10,10 +10,9 @@
];
class ShaderPass:
- def __init__(self, shaderType, maxaniso):
+ def __init__(self, shaderType):
self.st = shaderType
self.tex = [None for texunit in shaderType]
- self.maxaniso = maxaniso
def getTextureTypes(self):
return [texunit[1] for texunit in self.st]
def getTexgenTypes(self):
@@ -29,8 +28,6 @@
for t in range(0,len(self.st)):
target = self.st[t][0]
texid = self.tex[t].getTexId()
- minfilter = self.tex[t].minfilter
- magfilter = self.tex[t].magfilter
if texid == None: raise NoTextureSetForStage()
c += """
ActiveTexture TEXTURE%(t)s
@@ -41,21 +38,11 @@
Enable %(target)s
BindTexture %(target)s %(texid)s
-
- TexParameter %(target)s TEXTURE_WRAP_S REPEAT
- TexParameter %(target)s TEXTURE_WRAP_T REPEAT
- TexParameter %(target)s TEXTURE_MIN_FILTER %(minfilter)s
- TexParameter %(target)s TEXTURE_MAG_FILTER %(magfilter)s
""" % locals()
- if self.maxaniso != None:
- maxaniso = self.maxaniso
- c += """
- TexParameter %(target)s TEXTURE_MAX_ANISOTROPY_EXT %(maxaniso)s
- """ % locals()
return c
-def makeNormalShaderPass(maxaniso = None):
- return ShaderPass(shaderTypes[0], maxaniso)
+def makeNormalShaderPass():
+ return ShaderPass(shaderTypes[0])
scaleFactor = 1.0
Index: gzz/gfx/libpaper/textures.py
diff -u gzz/gfx/libpaper/textures.py:1.42 gzz/gfx/libpaper/textures.py:1.43
--- gzz/gfx/libpaper/textures.py:1.42 Thu Dec 5 09:34:49 2002
+++ gzz/gfx/libpaper/textures.py Fri Jan 31 07:09:49 2003
@@ -29,7 +29,11 @@
self.continuous = 1
self.minfilter = "LINEAR_MIPMAP_LINEAR"
self.magfilter = "LINEAR"
+ self.maxaniso = ""
+ if gzz.gfx.gl.GL.hasExtension("GL_EXT_texture_filter_anisotropic"):
+ self.maxaniso = "2.0"
+
# Update from specified values
self.__dict__.update(dict)
@@ -42,8 +46,15 @@
if not hasattr(self, "texture"):
print "Generating texture: ", self.name, self.args
self.texture = getCachedTexture(self.args)
- self.texture.setTexParameter("TEXTURE_2D", "TEXTURE_MIN_FILTER",
self.minfilter)
- self.texture.setTexParameter("TEXTURE_2D", "TEXTURE_MAG_FILTER",
self.magfilter)
+ # XXX: FIXME: 1D/3D textures!!!
+ target = "TEXTURE_2D"
+ self.texture.setTexParameter(target, "TEXTURE_WRAP_S", "REPEAT")
+ self.texture.setTexParameter(target, "TEXTURE_WRAP_T", "REPEAT")
+ self.texture.setTexParameter(target, "TEXTURE_MIN_FILTER",
self.minfilter)
+ self.texture.setTexParameter(target, "TEXTURE_MAG_FILTER",
self.magfilter)
+ if (self.maxaniso and (self.minfilter +
self.magfilter).find("NEAREST")):
+ self.texture.setTexParameter(target,
"TEXTURE_MAX_ANISOTROPY_EXT", self.maxaniso)
+
return self.texture.getTexId()
def getName(self):
Index: gzz/gfx/libutil/nvcode.py
diff -u gzz/gfx/libutil/nvcode.py:1.18 gzz/gfx/libutil/nvcode.py:1.19
--- gzz/gfx/libutil/nvcode.py:1.18 Fri Jan 31 04:27:44 2003
+++ gzz/gfx/libutil/nvcode.py Fri Jan 31 07:09:49 2003
@@ -616,23 +616,29 @@
# fp = GL.Program(foo.getFragmentProgram())
# --> bind and enable the returned program to emulate the combiners
#
-# ISSUES:
+# See convCombiner below for a simpler interface.
#
-# - The code is not yet tested and the interface is clumsy.
+# ISSUES:
#
# - How should the fragment program be attached to the corresponding
-# CallGL code?
+# CallGL code? (convCombiner below creates a hash table of all encountered
+# programs)
#
# - Creating a new fragment program is much more expensive than
-# modulating some register combiner options. E.g., in libpaper,
-# each paper would need its own emulating fragment program
-# because, even with the same combiner type, the scaling options
-# do change between papers.
+# modulating some register combiner options. In libpaper,
+# a large amount of different programs is needed, because
+# the discrete scaling options are modulated, too.
#
# - Should we try to create a single fragment program that could
# emulate all the "combiner programs"? (Seems impossible
# withouth indirect register accesses)
-
+#
+# Implementaion details:
+#
+# - only 2D textures can be accessed (no way to know which type is enabled)
+# - fog fraction is not implemented (requires unknown state)
+# - mux operation not yet implemented
+#
class fpCombiner:
def __init__(self):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/gfx demo/fontfilter.py libpaper/papermill.p...,
Janne V. Kujala <=