gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx/libpaper papermill.py


From: Vesa Kaihlavirta
Subject: [Gzz-commits] gzz/gfx/libpaper papermill.py
Date: Fri, 27 Sep 2002 07:53:12 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Vesa Kaihlavirta <address@hidden>       02/09/27 07:53:04

Modified files:
        gfx/libpaper   : papermill.py 

Log message:
        Tab/space fixed.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/papermill.py.diff?tr1=1.30&tr2=1.31&r1=text&r2=text

Patches:
Index: gzz/gfx/libpaper/papermill.py
diff -c gzz/gfx/libpaper/papermill.py:1.30 gzz/gfx/libpaper/papermill.py:1.31
*** gzz/gfx/libpaper/papermill.py:1.30  Tue Sep 24 09:09:24 2002
--- gzz/gfx/libpaper/papermill.py       Fri Sep 27 07:53:04 2002
***************
*** 14,31 ****
      # Discriminate between different renderers.
      # These are for debug output only.
      if dbg:
!       vendor = GL.getGLString("VENDOR")
!       renderer = GL.getGLString("RENDERER")
!       version = GL.getGLString("VERSION")
!       print "GL strings: '%s' '%s' '%s'"%(
!           vendor,renderer,version)
      # The backend files to load
      files = [
!       "textures.py",
!       "texcoords.py",
!       #"colors.py",
          "params.py"
!       ]
  
      #
      # Now, go through some questions.
--- 14,31 ----
      # Discriminate between different renderers.
      # These are for debug output only.
      if dbg:
!         vendor = GL.getGLString("VENDOR")
!         renderer = GL.getGLString("RENDERER")
!         version = GL.getGLString("VERSION")
!         print "GL strings: '%s' '%s' '%s'"%(
!             vendor,renderer,version)
      # The backend files to load
      files = [
!         "textures.py",
!         "texcoords.py",
!         #"colors.py",
          "params.py"
!         ]
  
      #
      # Now, go through some questions.
***************
*** 33,69 ****
  
      # Check which texture operations to use.
      if GL.hasExtension("GL_NV_texture_shader"):
!       # We can use the general texture shaders.
!       # XXX Should check separately for texture_shader2,
!       # otherwise it'll be SLOW.
!       if dbg: print "Using NV20 texture shaders"
!       files.append("texops_NV2X.py")
          #from gfx.libpaper.texops_NV2X import *
      else:
!       if dbg: print "Using unextended OpenGL texture accesses"
!       files.append("texops_STD.py")
          #from gfx.libpaper.texops_STD import *
  
  
      # Check which combiners to use.
      if 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:
!           # use NV10 version
!           if dbg: print "Using NV10 combiners ",maxcomb
!           files.append("texcomb_NV1X.py")
!       else:
!           # use NV20 version
!           if dbg: print "Using NV20 combiners ",maxcomb
!           files.append("texcomb_NV2X.py")
      else:
!       assert 0, "Sorry, can't do without NVIDIA register combiners yet."
  
      for f in files:
!       print "Load file ",f
!       execfile("gfx/libpaper/"+f, globals())
  
  def randvec(rnd): return [rnd.nextDouble() for i in range(0,3)]
  
--- 33,69 ----
  
      # Check which texture operations to use.
      if GL.hasExtension("GL_NV_texture_shader"):
!         # We can use the general texture shaders.
!         # XXX Should check separately for texture_shader2,
!         # otherwise it'll be SLOW.
!         if dbg: print "Using NV20 texture shaders"
!         files.append("texops_NV2X.py")
          #from gfx.libpaper.texops_NV2X import *
      else:
!         if dbg: print "Using unextended OpenGL texture accesses"
!         files.append("texops_STD.py")
          #from gfx.libpaper.texops_STD import *
  
  
      # Check which combiners to use.
      if 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:
!             # use NV10 version
!             if dbg: print "Using NV10 combiners ",maxcomb
!             files.append("texcomb_NV1X.py")
!         else:
!             # use NV20 version
!             if dbg: print "Using NV20 combiners ",maxcomb
!             files.append("texcomb_NV2X.py")
      else:
!         assert 0, "Sorry, can't do without NVIDIA register combiners yet."
  
      for f in files:
!         print "Load file ",f
!         execfile("gfx/libpaper/"+f, globals())
  
  def randvec(rnd): return [rnd.nextDouble() for i in range(0,3)]
  
***************
*** 83,100 ****
  
  def setSolidPass(pas, color):
      pas.setSetupcode("""
!       PushAttrib ENABLE_BIT TEXTURE_BIT
!       Disable REGISTER_COMBINERS_NV
!       Disable TEXTURE_2D
!       Disable BLEND
!       Enable DEPTH_TEST
          DepthFunc LESS
!       Color %(color)s
      """ % {
!           "color" : js(color),
!       })
      pas.setTeardowncode("""
!       PopAttrib
      """)
  
  def setDummyPass(pas):
--- 83,100 ----
  
  def setSolidPass(pas, color):
      pas.setSetupcode("""
!         PushAttrib ENABLE_BIT TEXTURE_BIT
!         Disable REGISTER_COMBINERS_NV
!         Disable TEXTURE_2D
!         Disable BLEND
!         Enable DEPTH_TEST
          DepthFunc LESS
!         Color %(color)s
      """ % {
!             "color" : js(color),
!         })
      pas.setTeardowncode("""
!         PopAttrib
      """)
  
  def setDummyPass(pas):
***************
*** 111,164 ****
      def getPaper(self, seed, passmask=[1,1,1,1,1,1,1]):
          reg = Registry()
          
!       pap = Paper()
  
!       passes = [ { "trans" : 0, "emboss" : 0 },
!                  { "trans" : .5, "emboss" : 0 },
!                  { "trans" : .9375, "emboss" : 0 },
!                  #{ "trans" : 0, "emboss" : 1 },
!                  ]
  
          rng = java.util.Random(reg.get(regseed, "seed", seed))
!       for foo in range(0,20): # eat bad beginning (Java's bad PRNG)
!           rng.nextInt()
!       seeds = [rng.nextInt(2000000000) for foo in passes]
  
          colors = Colors(rng.nextInt())
  
!       pap.setNPasses(len(passes))
!       #setSolidPass(pap.getPass(0), (0.1,0.1,0.2))
!       
!       for i in range(0, len(passes)):
!           if passmask[i]:
                  passreg = reg.sub("pass"+str(i))
                  passreg.get(regseed, "seed", seeds[i])
!               self.makePaperPass(passreg,
                                     pap.getPass(i), colors,
                                     passes[i]["trans"],
                                     emboss = passes[i]["emboss"])
!           else:
                  if i == 0:
                      setSolidPass(pap.getPass(i), (1,1,1))
                  else:
                      setDummyPass(pap.getPass(i))
  
          if dbg: reg.dump()
!       return pap
!       
      def makePaperPass(self, reg, ppass, colors, trans = 0, type = None, 
emboss = 0):
          seed = reg.get(regseed, "seed")
!       rnd = java.util.Random(seed)
!       #sh = ShaderPass(selectRandom(shaderTypes,rnd))
          if emboss:
              sh = makeEmbossShaderPass()
          else:
              sh = makeNormalShaderPass()
  
!       types = sh.getTextureTypes()
!       for i in range(0, len(types)):
!           if types[i] != None:
!               t = getPaperTexture(types[i], rnd)
  
                  if emboss:
                      if (i%2) == 0:
--- 111,164 ----
      def getPaper(self, seed, passmask=[1,1,1,1,1,1,1]):
          reg = Registry()
          
!         pap = Paper()
  
!         passes = [ { "trans" : 0, "emboss" : 0 },
!                    { "trans" : .5, "emboss" : 0 },
!                    { "trans" : .9375, "emboss" : 0 },
!                    #{ "trans" : 0, "emboss" : 1 },
!                    ]
  
          rng = java.util.Random(reg.get(regseed, "seed", seed))
!         for foo in range(0,20): # eat bad beginning (Java's bad PRNG)
!             rng.nextInt()
!         seeds = [rng.nextInt(2000000000) for foo in passes]
  
          colors = Colors(rng.nextInt())
  
!         pap.setNPasses(len(passes))
!         #setSolidPass(pap.getPass(0), (0.1,0.1,0.2))
!         
!         for i in range(0, len(passes)):
!             if passmask[i]:
                  passreg = reg.sub("pass"+str(i))
                  passreg.get(regseed, "seed", seeds[i])
!                 self.makePaperPass(passreg,
                                     pap.getPass(i), colors,
                                     passes[i]["trans"],
                                     emboss = passes[i]["emboss"])
!             else:
                  if i == 0:
                      setSolidPass(pap.getPass(i), (1,1,1))
                  else:
                      setDummyPass(pap.getPass(i))
  
          if dbg: reg.dump()
!         return pap
!         
      def makePaperPass(self, reg, ppass, colors, trans = 0, type = None, 
emboss = 0):
          seed = reg.get(regseed, "seed")
!         rnd = java.util.Random(seed)
!         #sh = ShaderPass(selectRandom(shaderTypes,rnd))
          if emboss:
              sh = makeEmbossShaderPass()
          else:
              sh = makeNormalShaderPass()
  
!         types = sh.getTextureTypes()
!         for i in range(0, len(types)):
!             if types[i] != None:
!                 t = getPaperTexture(types[i], rnd)
  
                  if emboss:
                      if (i%2) == 0:
***************
*** 176,241 ****
              # comb = DebugCombinerPass()
              comb = TransparentCombinerPass()
  
!       code = """
!           PushAttrib ENABLE_BIT TEXTURE_BIT DEPTH_BUFFER_BIT
!           Disable BLEND
!       """
  
!       # Performance optimization:
          # Set normal depth testing for the first (non-transparent) pass
          # and "equal" depth testing for the latter (transparent) passes,
!       # and don't write to the depth buffer.
  
          if trans == 0 and emboss == 0:
              code += """
!               Enable DEPTH_TEST
                  DepthFunc LESS
              """
          else:
              code += """
!               Enable DEPTH_TEST
                  DepthFunc EQUAL
                  DepthMask 0
              """
                  
          code += (
!           sh.setupCode() + 
!           comb.setupCode(sh.getRGBoutputs(), colors, rnd, trans)
!       )
! 
!       ppass.setSetupcode(code)
!       if dbg: print "SETUP: ", code
!       ppass.setTeardowncode("""
!           PopAttrib
              ActiveTexture TEXTURE0
!       """)
  
          eps = 1E-4
          
!       ttyp = sh.getTexgenTypes()
!       ppass.setNTexGens(len(ttyp))
  
!       rootrep = TexGenXYRepeatUnit(rnd)
  
!       for i in range(0, len(ttyp)):
!           if ttyp[i] != None:
!               sca2 = 0.8
  
!               if ttyp[i] in ("TexGen2D", "TexGen3D"):
!                   data = rootrep.getRelated(rnd).texCoords2D(rnd).getVec()
                  elif ttyp[i] == "TexGen2D":
                      data = TexCoords().texCoords2D(rnd).getVec()
                  elif ttyp[i] == "TexGen3D":
                      data = TexCoords().texCoords3D(rnd).getVec()
                      
!               elif ttyp[i] == "TexGenDotVector":
                      data = [ 0, 0, 0, sca2*rnd.nextGaussian(), 
                               0, 0, 0, sca2*rnd.nextGaussian(),
                               0, 0, 0, sca2*rnd.nextGaussian() ]
!               else:
!                   assert 0
!               if len(data) < 12:
!                   for i in (0,0,0,1): data.append(i)
                  if emboss :
                      if eps > 0:
                          prev = data
--- 176,241 ----
              # comb = DebugCombinerPass()
              comb = TransparentCombinerPass()
  
!         code = """
!             PushAttrib ENABLE_BIT TEXTURE_BIT DEPTH_BUFFER_BIT
!             Disable BLEND
!         """
  
!         # Performance optimization:
          # Set normal depth testing for the first (non-transparent) pass
          # and "equal" depth testing for the latter (transparent) passes,
!         # and don't write to the depth buffer.
  
          if trans == 0 and emboss == 0:
              code += """
!                 Enable DEPTH_TEST
                  DepthFunc LESS
              """
          else:
              code += """
!                 Enable DEPTH_TEST
                  DepthFunc EQUAL
                  DepthMask 0
              """
                  
          code += (
!             sh.setupCode() + 
!             comb.setupCode(sh.getRGBoutputs(), colors, rnd, trans)
!         )
! 
!         ppass.setSetupcode(code)
!         if dbg: print "SETUP: ", code
!         ppass.setTeardowncode("""
!             PopAttrib
              ActiveTexture TEXTURE0
!         """)
  
          eps = 1E-4
          
!         ttyp = sh.getTexgenTypes()
!         ppass.setNTexGens(len(ttyp))
  
!         rootrep = TexGenXYRepeatUnit(rnd)
  
!         for i in range(0, len(ttyp)):
!             if ttyp[i] != None:
!                 sca2 = 0.8
  
!                 if ttyp[i] in ("TexGen2D", "TexGen3D"):
!                     data = rootrep.getRelated(rnd).texCoords2D(rnd).getVec()
                  elif ttyp[i] == "TexGen2D":
                      data = TexCoords().texCoords2D(rnd).getVec()
                  elif ttyp[i] == "TexGen3D":
                      data = TexCoords().texCoords3D(rnd).getVec()
                      
!                 elif ttyp[i] == "TexGenDotVector":
                      data = [ 0, 0, 0, sca2*rnd.nextGaussian(), 
                               0, 0, 0, sca2*rnd.nextGaussian(),
                               0, 0, 0, sca2*rnd.nextGaussian() ]
!                 else:
!                     assert 0
!                 if len(data) < 12:
!                     for i in (0,0,0,1): data.append(i)
                  if emboss :
                      if eps > 0:
                          prev = data




reply via email to

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