/[gzz]/gzz/gfx/demo/irregularframe.py
ViewVC logotype

Diff of /gzz/gfx/demo/irregularframe.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by tjl, Wed Sep 11 06:35:14 2002 UTC revision 1.4 by tjl, Sat Sep 21 07:35:17 2002 UTC
# Line 5  from java.util import Random Line 5  from java.util import Random
5  from gzz.gfx.gl import Stencil  from gzz.gfx.gl import Stencil
6  from gfx.libutil import nvcode  from gfx.libutil import nvcode
7    
8    # w.window.resize(100,100)
9    
10    AbstractUpdateManager.defaultAnimationTime = 5000
11    AbstractUpdateManager.fractCalc = AbstractUpdateManager.LinearCalculator()
12    
13  stb = GZZGL.getGLFloat("STENCIL_BITS")[0]  stb = GZZGL.getGLFloat("STENCIL_BITS")[0]
14  print "Stencil: ",stb  print "Stencil: ",stb
15  if stb < 3:  if stb < 3:
# Line 21  t = GZZGL.createTexture() Line 26  t = GZZGL.createTexture()
26  t.shade(128, 128, 0, 4, "RGBA", "RGBA",  t.shade(128, 128, 0, 4, "RGBA", "RGBA",
27      "fnoise", ["scale", "0.05", "freq", "4", "df", "4", "bias", "0.5"])      "fnoise", ["scale", "0.05", "freq", "4", "df", "4", "bias", "0.5"])
28    
 if 0:  
     Stencil.initStencil = getDListNocoords("""  
      PushAttrib ENABLE_BIT STENCIL_BUFFER_BIT COLOR_BUFFER_BIT  
         Enable STENCIL_TEST  
         StencilFunc EQUAL 0 15  
         StencilOp ZERO ZERO INCR  
         StencilMask 1  
         ColorMask 0 0 0 0  
         Disable DEPTH_TEST  
     """)  
   
     Stencil.initOutside = getDListNocoords("""  
         StencilFunc EQUAL 0 15  
         ColorMask 1 1 1 1  
         StencilMask 0  
     """)  
   
29  execfile("gfx/libpaper/papermill.py")  execfile("gfx/libpaper/papermill.py")
30  papermill = ThePaperMill()  papermill = ThePaperMill()
31    
# Line 48  class IrreguScene: Line 36  class IrreguScene:
36              GZZGL.createPaperQuad(papermill.getPaper(seed), -1, -1.3, 1, 1.3)              GZZGL.createPaperQuad(papermill.getPaper(seed), -1, -1.3, 1, 1.3)
37                  for seed in self.range                  for seed in self.range
38          ]          ]
39            self.depthtest = 1
40    
41      def key(self, key):      def key(self, key):
42          pass          if key == 'd':
43                self.depthtest = not self.depthtest
44      def scene(self, vs):      def scene(self, vs):
45            putnoc(vs, getDListNocoords("""
46                Disable STENCIL_TEST
47                Enable DEPTH_TEST
48            """))
49          putnoc(vs, background((0.1,0.4,0.5)))          putnoc(vs, background((0.1,0.4,0.5)))
50            putnoc(vs, getDListNocoords("""
51                Disable STENCIL_TEST
52                Enable DEPTH_TEST
53                Disable TEXTURE_2D
54                Disable ALPHA_TEST
55                Disable BLEND
56                Disable STENCIL_TEST
57                StencilFunc ALWAYS 0 0
58                StencilOp ZERO ZERO ZERO
59                StencilMask 255
60            """))
61            # vs.put(coloredQuad((1,0,0)), "FOO", 500, -2, -2, vs.size.width+5, vs.size.height+5)
62            if 0:
63                # w.window.setCurrent()
64                # GZZGL.reallyClearStencilBuffer(1200,900)
65                # w.window.release()
66                n = vs.size.width * vs.size.height
67                buf = GZZGL.createByteVector(n)
68                buf.readFromBuffer_ubytes(w.window, "FRONT", 0, 0, vs.size.width, vs.size.height,
69                                        "STENCIL_INDEX")
70                print "NZ:"
71                hist = {}
72                for i in range(0,n):
73                    k = buf.get(i)
74                    hist[k] = hist.get(k, 0) + 1
75                print hist
76                buf.readFromBuffer_ubytes(w.window, "FRONT", 0, 0, vs.size.width, vs.size.height,
77                                        "DEPTH_COMPONENT")
78                print "NZD:"
79                hist = {}
80                for i in range(0,n):
81                    k = buf.get(i)
82                    hist[k] = hist.get(k, 0) + 1
83                print hist
84    
85    
         pcs = vs.coords.affineCoordsys(0, "P",  
             20, 0, 0, 200, 0,0, 200)  
86    
87          for i in self.range:          for i in self.range:
88    
89              rs = 10              rs = 10
90              ro = 50              ro = 50
91              sz = 10 + 200 * du()              sz = 10 + vs.size.width/10 * du()
92              pl = 1000              pl = vs.size.width
93              stencs = vs.coords.affineCoordsys(0, "STM%s"%i,              stencs = vs.coords.affineCoordsys(0, "STM%s"%i,
94                  10, pl*du(), pl*du(), sz+rs*ds(), rs*ds(), rs*ds(), sz+rs*ds())                  10*du(), pl*du(), pl*du(), sz+rs*ds(), rs*ds(), rs*ds(), sz+rs*ds())
95    
96                pcs = vs.coords.affineCoordsys(0, "P",
97                    20*du(), ro*ds(), ro*ds(), 200*ds(), 0,0, 200*ds())
98                            
99              class simplemask(Runnable):              class simplemask(Runnable):
100                  def run(self):                  def run(self):
# Line 126  class IrreguScene: Line 156  class IrreguScene:
156                          Disable REGISTER_COMBINERS_NV                          Disable REGISTER_COMBINERS_NV
157                      """%(t.getTexId())), stencs)                      """%(t.getTexId())), stencs)
158    
             putnoc(vs, getDListNocoords("Disable DEPTH_TEST\nColor 1 1 1\n"))  
159                            
160              class outside(Runnable):              class outside(Runnable):
161                  def run(self):                  def run(self):
# Line 149  class IrreguScene: Line 178  class IrreguScene:
178                      """))                      """))
179                      vs.map.put(pq, stencs, pcs)                      vs.map.put(pq, stencs, pcs)
180    
181    
182                print "Depthtest: ",self.depthtest
183                if self.depthtest:
184                    putnoc(vs, getDListNocoords("Enable DEPTH_TEST\nColor 1 1 1\n"))
185                else:
186                    putnoc(vs, getDListNocoords("Disable DEPTH_TEST\nColor 1 1 1\n"))
187    
188              Stencil.drawStenciled(vs, simplemask(), None, outside(),              Stencil.drawStenciled(vs, simplemask(), None, outside(),
189                  contents(), 0)                  contents(), 0)
190    
191    
192  currentScene = IrreguScene()  currentScene = IrreguScene()

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26