gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/papertest-dual.py libpaper/papermi...


From: Vesa Kaihlavirta
Subject: [Gzz-commits] gzz/gfx demo/papertest-dual.py libpaper/papermi...
Date: Thu, 14 Nov 2002 09:59:17 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Vesa Kaihlavirta <address@hidden>       02/11/14 09:59:16

Modified files:
        gfx/demo       : papertest-dual.py 
        gfx/libpaper   : papermill.py textures.py 

Log message:
        Works with all combiners in the same scene (useful in papertest).

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/papertest-dual.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.62&tr2=1.63&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/textures.py.diff?tr1=1.36&tr2=1.37&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/papertest-dual.py
diff -u gzz/gfx/demo/papertest-dual.py:1.1 gzz/gfx/demo/papertest-dual.py:1.2
--- gzz/gfx/demo/papertest-dual.py:1.1  Thu Nov 14 08:03:50 2002
+++ gzz/gfx/demo/papertest-dual.py      Thu Nov 14 09:59:16 2002
@@ -236,7 +236,7 @@
         self.w = 4
         self.h = 3
         self.seed = 0
-        self.initpaper()
+        # self.initpaper()
 
     def initpaper(self):
         self.pq = range(0,self.w*self.h)
@@ -289,7 +289,7 @@
         self.boxes = []
         cs1 = range(0,self.w*self.h)
         for i in range(0,self.w*self.h):
-            if i >= len(self.pq): break
+            # if i >= len(self.pq): break
 
             x = (i%self.w+.5)*size.width/self.w
             y = (i/self.w+.5)*size.height/self.h
@@ -303,13 +303,13 @@
             if gzz.gfx.gl.PaperOptions.use_opengl_1_1:
                 vs.matcher.add(cs1[i], str(i))
             
-                vs.map.put(self.pq[i], cs1[i], cs2)
+                vs.map.put(getpaper(self.seed + i), cs1[i], cs2)
                 putText(vs, cs1[i], str(self.seed + i), color=(0,0,0), 
x=-1,y=1,z=-1, h=.5, key=str(i))
                 gzz.gfx.gl.PaperOptions.use_opengl_1_1 = not 
gzz.gfx.gl.PaperOptions.use_opengl_1_1
             else:
                 vs.matcher.add(cs1[i],'dual'+ str(i))
             
-                vs.map.put(self.pq[i-1], cs1[i], cs2)
+                vs.map.put(getpaper(self.seed + i - 1), cs1[i], cs2)
                 putText(vs, cs1[i], str(self.seed + i -1), color=(0,0,0), 
x=-1,y=1,z=-1, h=.5, key='dual'+str(i-1))
                 gzz.gfx.gl.PaperOptions.use_opengl_1_1 = not 
gzz.gfx.gl.PaperOptions.use_opengl_1_1
 
Index: gzz/gfx/libpaper/papermill.py
diff -u gzz/gfx/libpaper/papermill.py:1.62 gzz/gfx/libpaper/papermill.py:1.63
--- gzz/gfx/libpaper/papermill.py:1.62  Thu Nov 14 07:06:22 2002
+++ gzz/gfx/libpaper/papermill.py       Thu Nov 14 09:59:16 2002
@@ -7,12 +7,16 @@
 from gfx.libpaper.params import *
 from gzz.vob.vobs import SolidBgVob
 
+import gfx.libpaper.texcomb_NV1X
+import gfx.libpaper.texcomb_NV2X
+import gfx.libpaper.texcomb_GL1_1
+
 from gzz.gfx.gl import GL,GLRen,Paper,PaperMill
 import java
 from java.lang import Math
 
 from gzz.gfx.gl import PaperOptions
-tmp = PaperOptions();
+tmp = PaperOptions.instance();
 use_opengl_1_1 = tmp.use_opengl_1_1
 
 dbg=1
@@ -30,7 +34,7 @@
 #
 
 # Check which texture operations to use.
-if not use_opengl_1_1 and GL.hasExtension("GL_NV_texture_shader"):
+if not use_opengl_1_1 and GL.hasExtension("GL_NV_texture_shader3"):
     # We can use the general texture shaders.
     # XXX Should check separately for texture_shader2,
     # otherwise it'll be SLOW.
@@ -42,26 +46,6 @@
     from gfx.libpaper.texops_STD import makeNormalShaderPass, scaleFactor
     numpasses = 3
 
-# Check which combiners to use.
-if not use_opengl_1_1 and GL.hasExtension("GL_NV_register_combiners"):
-    # 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]
-    #if maxcomb < 4:
-    if 1: #XXX NV20 version is broken
-        # use NV10 version
-        if dbg: print "Using NV10 combiners ",maxcomb
-        from gfx.libpaper.texcomb_NV1X import 
TransparentCombinerPass,DebugCombinerPass
-    else:
-        # use NV20 version
-        if dbg: print "Using NV20 combiners ",maxcomb
-        from gfx.libpaper.texcomb_NV2X import 
TransparentCombinerPass,DebugCombinerPass
-else:
-    # Must use OpenGL 1.1 specified calls.
-    print "NEED FIX - DOES _NOT_ WORK : Using OpenGL 1.1 texenv and blending"
-    from gfx.libpaper.texcomb_GL1_1 import *
-    gfx.libpaper.textures.texture_format = "LUMINANCE_ALPHA"
-    gfx.libpaper.textures.texture_components = 2
 
 # Check whether anisotropic filtering is supported
 if GL.hasExtension("GL_EXT_texture_filter_anisotropic"):
@@ -104,6 +88,8 @@
     pass
 
 class ThePaperMill(PaperMill):
+    paperopts = PaperOptions.instance()
+    
     def getPaper(self, seed, passmask=[1,1,1,1,1,1,1]):
         pap = PaperHanger()
         pap.reg = Registry()
@@ -223,7 +209,39 @@
 
        return npap
 
+
+    def selectCombiner(self):
+        # Check which combiners to use.
+        if not self.paperopts.use_opengl_1_1 and 
GL.hasExtension("GL_NV_register_combiners"):
+            # 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]
+    #if maxcomb < 4:
+            if 1: #XXX NV20 version is broken
+                # use NV10 version
+                if dbg: print "Using NV10 combiners ",maxcomb
+                texcomb = gfx.libpaper.texcomb_NV1X
+                # from gfx.libpaper.texcomb_NV1X import 
TransparentCombinerPass,DebugCombinerPass
+            else:
+                # use NV20 version
+                if dbg: print "Using NV20 combiners ",maxcomb
+                texcomb = gfx.libpaper.texcomb_NV2X
+                #from gfx.libpaper.texcomb_NV2X import 
TransparentCombinerPass,DebugCombinerPass
+        else:
+            # Must use OpenGL 1.1 specified calls.
+            print "NEED FIX - DOES _NOT_ WORK : Using OpenGL 1.1 texenv and 
blending"
+            #from gfx.libpaper.texcomb_GL1_1 import *
+            texcomb = gfx.libpaper.texcomb_GL1_1
+            gfx.libpaper.textures.texture_format = "LUMINANCE_ALPHA"
+            gfx.libpaper.textures.texture_components = 2
+
+        self.TransparentCombinerPass = texcomb.TransparentCombinerPass
+        self.DebugCombinerPass = texcomb.DebugCombinerPass
+
+
+
     def makePaperPass(self, reg, ppass, colors, textures, rootrep, trans = 0, 
emboss = 0):
+        self.selectCombiner()
         seed = reg.get(regseed, "seed")
         rnd = java.util.Random(seed)
         if emboss:
@@ -249,8 +267,8 @@
         if emboss:
             comb = EmbossCombinerPass()
         else:
-            #comb = DebugCombinerPass()
-            comb = TransparentCombinerPass()
+            #comb = self.DebugCombinerPass()
+            comb = self.TransparentCombinerPass()
 
         code = """
             PushAttrib ENABLE_BIT TEXTURE_BIT DEPTH_BUFFER_BIT 
COLOR_BUFFER_BIT CURRENT_BIT
Index: gzz/gfx/libpaper/textures.py
diff -u gzz/gfx/libpaper/textures.py:1.36 gzz/gfx/libpaper/textures.py:1.37
--- gzz/gfx/libpaper/textures.py:1.36   Thu Nov 14 08:44:54 2002
+++ gzz/gfx/libpaper/textures.py        Thu Nov 14 09:59:16 2002
@@ -10,6 +10,7 @@
 #      OFFS3
 
 
+import gzz.gfx.gl
 import java
 from math import exp
 
@@ -49,7 +50,7 @@
 
 
 initialized = 0
-def init():
+def init(texture_components, texture_format):
     """Creates and returns textures.""" # XXX need more doc here
     global initialized
     initialized = 1
@@ -343,11 +344,17 @@
 
 class Textures:
     textures = None
+    paperopt = gzz.gfx.gl.PaperOptions.instance()
     def __init__(self, seed):
+        text_comps, text_form = texture_components, texture_format
         if not self.textures:
-            self.textures = init()
-            print "DEBUG: Textures created"
-
+            
+            if not self.paperopt.use_opengl_1_1:
+                text_comps, text_form = 2, 'LUMINANCE_ALPHA'
+
+            self.textures = init(text_comps, text_form)
+            print "Textures created: components: %d, format: %s" % 
(text_comps, text_form)
+            
        rnd = java.util.Random(seed)
 
         hyper = rnd.nextGaussian()*5




reply via email to

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