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

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

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

revision 1.7 by jvk, Tue Nov 12 09:53:49 2002 UTC revision 1.8 by jvk, Wed Nov 13 14:10:09 2002 UTC
# Line 2  from gfx.libutil.nvcode import combinerc Line 2  from gfx.libutil.nvcode import combinerc
2  from gfx.libpaper.texcache import getCachedTexture  from gfx.libpaper.texcache import getCachedTexture
3  from math import sin,cos  from math import sin,cos
4    
5    from gfx.libpaper.papermill import ThePaperMill
6    
7    seed = 200
8    pap = ThePaperMill().getPaper(seed)
9    paperquad = GLRen.createPaperQuad(pap, -2, -2, 2, 2, 0)
10    
11    
12  ripple_scale = 0.25  ripple_scale = 0.25
13  texRGBA = getCachedTexture([128, 128, 0, 4, "RGBA", "RGBA",  texRGBA = getCachedTexture([128, 128, 0, 4, "RGBA", "RGBA",
14                           "irregu", ["radius", "2",                           "irregu", ["radius", "2",
# Line 34  class IrreguScene: Line 41  class IrreguScene:
41    
42          self.initcode()          self.initcode()
43    
44            self.stencil_init = getDListNocoords("""
45            # Create stencil
46            StencilMask 255
47            Enable STENCIL_TEST
48            StencilFunc ALWAYS 0 255
49            StencilOp INCR INCR INCR
50            ColorMask 0 0 0 0
51            """)
52    
53            self.stencil_use = getDListNocoords("""
54            Enable STENCIL_TEST
55            StencilFunc NOTEQUAL 0 255
56            StencilOp ZERO ZERO ZERO
57            ColorMask 1 1 1 1
58            """)
59    
60            self.stencil_teardown = getDListNocoords("""
61            Disable STENCIL_TEST
62            """)
63    
64      def initcode(self):      def initcode(self):
65          code = combinercode("""          code = combinercode("""
66                  PushAttrib ENABLE_BIT TEXTURE_BIT                  PushAttrib ENABLE_BIT TEXTURE_BIT
# Line 184  class IrreguScene: Line 211  class IrreguScene:
211          SLICE_1D      = 16;          SLICE_1D      = 16;
212          SLICE_2D      = 32;          SLICE_2D      = 32;
213          SHIFTS        = 64;          SHIFTS        = 64;
214            INSIDE        = 128;
215    
216          inner_code = code % {"tex" : texRGBA.getTexId(),          inner_code = code % {"tex" : texRGBA.getTexId(),
217                               "color" : "1 1 1 1" }                               "color" : "1 1 1 1" }
# Line 198  class IrreguScene: Line 226  class IrreguScene:
226          border1 = .5 * ripple_scale * texscale          border1 = .5 * ripple_scale * texscale
227          texslicing = self.texslicing          texslicing = self.texslicing
228    
         SLICE = (SLICE_2D, SLICE_1D)[self.flags >> 4 & 1]  
   
229          stdcode = """          stdcode = """
230              PushAttrib ENABLE_BIT TEXTURE_BIT              PushAttrib ENABLE_BIT TEXTURE_BIT
231              BindTexture TEXTURE_2D %s              BindTexture TEXTURE_2D %s
# Line 216  class IrreguScene: Line 242  class IrreguScene:
242              border0, border1, texslicing,              border0, border1, texslicing,
243              "0 0 0 1 0 0 0 0", "",              "0 0 0 1 0 0 0 0", "",
244              0, 0,              0, 0,
245              SLICE + Y_COLOR + SHIFTS, stdcode + """              SLICE_1D + Y_COLOR + SHIFTS, stdcode + """
246              BlendFunc ZERO ZERO              BlendFunc ZERO ZERO
247              Enable BLEND              Enable BLEND
248              """, 1.0)              """, 1.0)
# Line 231  class IrreguScene: Line 257  class IrreguScene:
257              border0, border1, texslicing,              border0, border1, texslicing,
258              ("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], "",              ("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], "",
259              0, 0,              0, 0,
260              SLICE + Y_COLOR, stdcode, 1.0)              SLICE_1D + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, stdcode, 1.0)
261    
262          if GL.hasExtension("GL_NV_register_combiners") and 0:          if GL.hasExtension("GL_NV_register_combiners") and 0:
263              self.outer = GLRen.createIrregularEdge(              self.outer = GLRen.createIrregularEdge(
264                  texscale, linewidth, refsize, scale_pow,                  texscale, linewidth, refsize, scale_pow,
265                  border0, border1, texslicing,                  border0, border1, texslicing,
266                  "1 1 1 1 0 0 0 0", "", 3, 0,                  "1 1 1 1 0 0 0 0", "", 3, 0,
267                  Y_SECCOLOR + SLICE + DOTVEC_COLOR + INTERP_DOTVEC,                  Y_SECCOLOR + SLICE_1D + DOTVEC_COLOR + INTERP_DOTVEC,
268                  outer_code, 1.0)                  outer_code, 1.0)
269                            
270          if (GL.hasExtension("GL_NV_register_combiners") and          if (GL.hasExtension("GL_NV_register_combiners") and
# Line 251  class IrreguScene: Line 277  class IrreguScene:
277                  texscale, linewidth, refsize, scale_pow,                  texscale, linewidth, refsize, scale_pow,
278                  border0, border1, texslicing,                  border0, border1, texslicing,
279                  "1 1 1 1 0 0 0 0", "", 0, 1,                  "1 1 1 1 0 0 0 0", "", 0, 1,
280                  Y_SECCOLOR + SLICE,                  Y_SECCOLOR + SLICE_1D,
281                  outer_code, 1.0)                  outer_code, 1.0)
282    
283    
# Line 271  class IrreguScene: Line 297  class IrreguScene:
297                                         self.scale * 0,                                         self.scale * 0,
298                                         self.scale * 0,                                         self.scale * 0,
299                                         self.scale * 150)                                         self.scale * 150)
300    
301            cspap = vs.coords.affineCoordsys(0, 0, 0, 0, 1, 0, 0, 1)
302            vs.matcher.add(cspap, "pap")
303                                            
304    
305          vs.matcher.add(cs1, "1")          vs.matcher.add(cs1, "1")
306    
307          if self.flags & 8:          if self.flags & 8:
308              vs.map.put(self.outer, cs1, cs2)              vs.map.put(self.outer, cs1, cs2)
309    
310          if self.flags & 7:          if self.flags & 7:
311                if self.flags & 32:
312                    vs.map.put(self.stencil_init)
313                    
314              vs.map.put(self.inner, cs1, cs2)              vs.map.put(self.inner, cs1, cs2)
315    
316                if self.flags & 32:
317                    vs.map.put(self.stencil_use)
318                    vs.map.put(paperquad, cs1, cspap)
319                    
320                    vs.map.put(self.stencil_teardown)
321    
322    
323          print "1: ADD TEXTURE", self.flags >> 0& 1          print "1: ADD TEXTURE", self.flags >> 0& 1
324          print "2: ADD COLOR", self.flags >> 1 & 1          print "2: ADD COLOR", self.flags >> 1 & 1
325          print "3: ALPHA_TEST", self.flags >> 2 & 1          print "3: ALPHA_TEST", self.flags >> 2 & 1
326          print "4: OUTER EDGE", self.flags >> 3 & 1          print "4: OUTER EDGE", self.flags >> 3 & 1
327          print "5: 1D SLICE", self.flags >> 4 & 1          print "5: INSIDE", self.flags >> 4 & 1
328            print "6: STENCIL", self.flags >> 5 & 1
329    
330      def key(self, k):      def key(self, k):
331          if 0: pass          if 0: pass

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

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