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

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

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

revision 1.44 by jvk, Sat Nov 2 14:51:36 2002 UTC revision 1.45 by jvk, Tue Nov 5 13:23:40 2002 UTC
# Line 21  profiles = [] Line 21  profiles = []
21    
22  if (GL.hasExtension("GL_NV_fragment_program")):  if (GL.hasExtension("GL_NV_fragment_program")):
23      profiles.append("NV_PROG")      profiles.append("NV_PROG")
24        profiles.append("NV_PROG2")
25    
26  if (GL.hasExtension("GL_NV_texture_shader")):  if (GL.hasExtension("GL_NV_texture_shader")):
27      profiles.append("NV_SHAD")      profiles.append("NV_SHAD")
# Line 76  def init(): Line 77  def init():
77    
78      print "Using profile:", profile      print "Using profile:", profile
79    
80      if profile == "NV_PROG":      if profile == "NV_PROG" or profile == "NV_PROG2":
81          print "Using 2-vector HILO displacement texture with GL_NV_fragment_program"          print "Using 2-vector HILO displacement texture with GL_NV_fragment_program"
82          using_fragprog = 1          using_fragprog = 1
83                    
# Line 148  def init(): Line 149  def init():
149          END          END
150          """          """
151    
152            if profile == "NV_PROG2":
153                # "Flood fill" implementation; NOT TESTED
154                
155                code = """
156                # f[TEX0].xyw texture coordinates
157                # f[TEX2].xy texture HI and LO component weights
158                # f[TEX2].w  displacement (added to the weighted texture value)
159    
160                # Read texture
161                TXP R0, f[TEX0], TEX0, 2D;
162    
163                # Weight, add displacement, and use as output color
164                DP4 R0, R0, f[TEX2];
165    
166                # R0 <- (R0 >= 1.0)
167                SGE R0, R0, 1.0;
168                
169                # R1 <- 2 grad(R0) . grad(R0)
170                DDX R1.x, R0;
171                DDY R1.y, R0;
172                DP4 R1, R1.xyxy, R1.xyxy;
173                
174                # R2 <- 2 grad(R1) . grad(R1)
175                DDX R2.x, R1;
176                DDY R2.x, R1;
177                DP4 R2, R2.xyxy, R2.xyxy;
178                
179                # Use R1 + R2 > 0 as the output color
180                ADD R1, R1, R2;
181                SGE o[COLR], R1, 0.0;
182                """
183    
184          prog_outer = GL.createProgram(code)          prog_outer = GL.createProgram(code)
185    
186                    
# Line 435  def globalkey(k): Line 468  def globalkey(k):
468          init()          init()
469      elif "F1" <= k <= "F9":      elif "F1" <= k <= "F9":
470          global profile          global profile
471          profile = profiles[int(k[1]) - 1]          profile = profiles[int(k[1:]) - 1]
472          init()          init()
473      elif k == "m":      elif k == "m":
474          global matrices          global matrices
# Line 876  class IrreguScene: Line 909  class IrreguScene:
909          if k == "Next":          if k == "Next":
910              self.angle += pi/180; print "angle",round(self.angle / pi * 180)              self.angle += pi/180; print "angle",round(self.angle / pi * 180)
911              reinit = 1              reinit = 1
912          if k == "Home": self.angle2 -= pi/180; self.angle += pi/180          if k == "Home": self.angle2 -= pi/180; self.angle += pi/180; reinit = 1
913          if k == "End": self.angle2 += pi/180; self.angle -= pi/180          if k == "End": self.angle2 += pi/180; self.angle -= pi/180; reinit = 1
914    
915          if k == "i": self.use_stencil = not self.use_stencil          if k == "i": self.use_stencil = not self.use_stencil
916                            

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

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