/[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.33 by jvk, Sat Nov 30 19:40:42 2002 UTC revision 1.34 by jvk, Sat Nov 30 21:42:58 2002 UTC
# Line 51  def inittex(): Line 51  def inittex():
51             ]],             ]],
52          shade_all_levels = 1)          shade_all_levels = 1)
53    
54        global stdcode
55        stdcode = """
56        PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT
57        BindTexture TEXTURE_2D %s
58        TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR
59        TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
60        Enable TEXTURE_2D
61        TexEnv TEXTURE_ENV TEXTURE_ENV_MODE ADD
62        Enable ALPHA_TEST
63        AlphaFunc GEQUAL 1.0
64        #MatrixMode TEXTURE
65        #LoadMatrix 2 0 0 0  0 1 0 0  0 0 1 0  0 0 0 1
66        #MatrixMode MODELVIEW
67        """ % texINTENSITY.getTexId()
68    
69    
70      if GL.hasExtension("GL_NV_register_combiners"):      if GL.hasExtension("GL_NV_register_combiners"):
71          texRGBA = getCachedTexture(          texRGBA = getCachedTexture(
72              [128, 128, 0, 4, "RGBA", "RGBA", "irregu",              [128, 128, 0, 4, "RGBA", "RGBA", "irregu",
# Line 329  class IrreguScene: Line 345  class IrreguScene:
345          border1 = .5 * ripple_scale * texscale          border1 = .5 * ripple_scale * texscale
346          texslicing = self.texslicing          texslicing = self.texslicing
347    
348          stdcode = """  
349              PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT          code = stdcode
             BindTexture TEXTURE_2D %s  
             TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR  
             TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR  
             Enable TEXTURE_2D  
             TexEnv TEXTURE_ENV TEXTURE_ENV_MODE ADD  
             Enable ALPHA_TEST  
             AlphaFunc GEQUAL 1.0  
             #MatrixMode TEXTURE  
             #LoadMatrix 2 0 0 0  0 1 0 0  0 0 1 0  0 0 0 1  
             #MatrixMode MODELVIEW  
             """ % texINTENSITY.getTexId()  
350    
351          c1 = ""          c1 = ""
352          slice = SLICE_1D + (1 - (self.flags >> 6 & 1)) * SLICE_2D;          slice = SLICE_1D + (1 - (self.flags >> 6 & 1)) * SLICE_2D;
353          if slice & SLICE_2D:          if slice & SLICE_2D:
354              c1 = "1 1 1 0  0 0 0 0"              c1 = "1 1 1 0  0 0 0 0"
355              slice += Y_SECCOLOR              slice += Y_SECCOLOR
356              stdcode += combinercode("""              code += combinercode("""
357              SecondaryColorEXT .5 .5 .5              SecondaryColorEXT .5 .5 .5
358                            
359              ActiveTexture TEXTURE1              ActiveTexture TEXTURE1
# Line 400  class IrreguScene: Line 405  class IrreguScene:
405              "0 0 0 1 0 0 0 0", c1,              "0 0 0 1 0 0 0 0", c1,
406              0, 0,              0, 0,
407              slice + Y_COLOR + SHIFTS + outerflags,              slice + Y_COLOR + SHIFTS + outerflags,
408              stdcode + """              code + """
409              BlendFunc ZERO ZERO              BlendFunc ZERO ZERO
410              Enable BLEND              Enable BLEND
411              """, 1.0)              """, 1.0)
412    
         self.clear = GLRen.createIrregularEdge(shape,  
             texscale, linewidth, refsize, scale_pow,  
             border0, border1, texslicing,  
             "", "",  
             0, 0,  
             SLICE_2D + (self.flags >> 4 & 1) * INSIDE, """  
             PushAttrib ENABLE_BIT  
             Disable TEXTURE_2D  
             Disable ALPHA_TEST  
             Color 0 0 0  
             """, 1.0)  
   
413          self.envelope = GLRen.createIrregularEdge(shape,          self.envelope = GLRen.createIrregularEdge(shape,
414              texscale, linewidth, refsize, scale_pow,              texscale, linewidth, refsize, scale_pow,
415              border0, border1, texslicing,              border0, border1, texslicing,
# Line 448  class IrreguScene: Line 441  class IrreguScene:
441              border0, border1, texslicing,              border0, border1, texslicing,
442              "0 0 0 1 0 0 0 0", c1,              "0 0 0 1 0 0 0 0", c1,
443              0, 0,              0, 0,
444              slice + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, stdcode +              slice + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, code +
445                                                  combinercode("""                                                  combinercode("""
446              Enable REGISTER_COMBINERS_NV              Enable REGISTER_COMBINERS_NV
447              CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1              CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
# Line 472  class IrreguScene: Line 465  class IrreguScene:
465              """), 1.0)              """), 1.0)
466    
467          if (self.flags & 1) == 0:          if (self.flags & 1) == 0:
468              stdcode += "Disable TEXTURE_2D\n"              code += "Disable TEXTURE_2D\n"
469          if (self.flags & 4) == 0:          if (self.flags & 4) == 0:
470              stdcode += "Disable ALPHA_TEST\n"              code += "Disable ALPHA_TEST\n"
471                            
472          self.inner = GLRen.createIrregularEdge(shape,          self.inner = GLRen.createIrregularEdge(shape,
473              texscale, linewidth, refsize, scale_pow,              texscale, linewidth, refsize, scale_pow,
474              border0, border1, texslicing,              border0, border1, texslicing,
475              ("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], c1,              ("0 0 0 0 0 0 0 0", "1 1 1 1 0 0 0 0")[self.flags >> 1 & 1], c1,
476              0, 0,              0, 0,
477              slice + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, stdcode, 1.0)              slice + Y_COLOR + (self.flags >> 4 & 1) * INSIDE, code, 1.0)
478    
479          if GL.hasExtension("GL_NV_register_combiners") and 1:          if GL.hasExtension("GL_NV_register_combiners") and 1:
480              self.outer = GLRen.createIrregularEdge(shape,              self.outer = GLRen.createIrregularEdge(shape,
# Line 552  class IrreguScene: Line 545  class IrreguScene:
545          cspap = vs.coords.affineCoordsys(0, 0, 0, 0, 1, 0, 0, 1)          cspap = vs.coords.affineCoordsys(0, 0, 0, 0, 1, 0, 0, 1)
546          vs.matcher.add(cspap, "pap")          vs.matcher.add(cspap, "pap")
547    
         #vs.map.put(self.clear)  
548          if self.flags & 128:          if self.flags & 128:
549              vs.map.put(self.shadow, cs1shadow, cs2)              vs.map.put(self.shadow, cs1shadow, cs2)
550    
# Line 656  class IrreguScene: Line 648  class IrreguScene:
648          pass          pass
649    
650    
651    class ShapeScene:
652        def scene(self, vs):
653            putnoc(vs, background((1.0,1.0,1.0)))
654    
655            xs = 256
656            ys = 256
657    
658            w = 2
659            h = 2
660            for y in range(0,h):
661                for x in range(0,w):
662    
663                    
664                    shape = 10
665                    texscale = 1
666                    linewidth = 4
667                    refsize = 128
668                    scale_pow = 0
669                    border0 = -.5 * ripple_scale * texscale
670                    border1 = .5 * ripple_scale * texscale
671                    texslicing = 0.0
672                    
673                    edge = GLRen.createIrregularEdge(
674                        shape, texscale, linewidth, refsize, scale_pow,
675                        border0, border1, texslicing,
676                        "0 0 0 1 0 0 0 0", "", 0, 0, SLICE_1D + Y_COLOR, # + INSIDE,
677                        stdcode, 1.0)
678                    
679                    cs1 = vs.coords.affineCoordsys(0, 10,
680                                                   (x+1) * xs, (y+1) * ys,
681                                                   xs/3., 0, 0, ys/3.,
682                                                   )
683                
684                    vs.matcher.add(cs1, "1,%s,%s" % (x,y))
685                    
686                    cs2 = vs.coords.affineCoordsys(0, 0,  0, 0,   1, 0, 0, 1);
687                    vs.matcher.add(cs1, "2")
688                    
689                    vs.map.put(edge, cs1, cs2)
690    
691    
692    
693  class StillMotionScene:  class StillMotionScene:
694      def __init__(self, type = 0, flag = 0):      def __init__(self, type = 0, flag = 0):
695          self.scale = 700          self.scale = 700
# Line 669  class StillMotionScene: Line 703  class StillMotionScene:
703              self.x0, self.y0 = -.35, -.65              self.x0, self.y0 = -.35, -.65
704              self.x1, self.y1 = .35, .65              self.x1, self.y1 = .35, .65
705              self.xs, self.ys = .6,.4              self.xs, self.ys = .6,.4
               
   
         stdcode = """  
         PushAttrib ENABLE_BIT TEXTURE_BIT CURRENT_BIT  
         BindTexture TEXTURE_2D %s  
         TexParameter TEXTURE_2D TEXTURE_MIN_FILTER LINEAR_MIPMAP_LINEAR  
         TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR  
         Enable TEXTURE_2D  
         TexEnv TEXTURE_ENV TEXTURE_ENV_MODE ADD  
         TexEnv TEXTURE_FILTER_CONTROL_EXT TEXTURE_LOD_BIAS_EXT 0  
         Enable ALPHA_TEST  
         AlphaFunc GEQUAL 1.0  
         """ % texINTENSITY.getTexId()  
   
706            
707          shape = 10          shape = 10
708          if type == 1: shape = 7          if type == 1: shape = 7
# Line 897  currentScene = IrreguScene() Line 917  currentScene = IrreguScene()
917    
918  #currentScene = StillMotionScene(type = 1, flag = 1)  #currentScene = StillMotionScene(type = 1, flag = 1)
919    
920    #currentScene = ShapeScene()
921    
922  #GL.call("PolygonMode FRONT_AND_BACK FILL")  #GL.call("PolygonMode FRONT_AND_BACK FILL")

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

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