gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/gfx demo/texlab.py libpaper/textures.py lib...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx demo/texlab.py libpaper/textures.py lib...
Date: Tue, 08 Oct 2002 12:09:54 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/10/08 12:09:54

Modified files:
        gfx/demo       : texlab.py 
        gfx/libpaper   : textures.py 
        gfx/libtexture : geometric.texture 

Log message:
        Add some framework for entering libpaper texture properties

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/texlab.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/textures.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/geometric.texture.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/texlab.py
diff -c gzz/gfx/demo/texlab.py:1.4 gzz/gfx/demo/texlab.py:1.5
*** gzz/gfx/demo/texlab.py:1.4  Tue Oct  8 06:29:52 2002
--- gzz/gfx/demo/texlab.py      Tue Oct  8 12:09:54 2002
***************
*** 1,34 ****
  # A simple window for testing shaders and adjusting parameters
  from __future__ import nested_scopes
  
  import math
  
  #tex = GL.createTexture()
  
! 
! #tex.shade(256, 256, 0, 3, "RGB", "RGB", "fnoise",
! #          ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5", "seed", 
"1412"])
! #tex.shade(256, 256, 0, 3, "RGB", "RGB", "fnoise",
! #          ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"])
! 
! #tex.shade(256, 256, 0, 4, "RGBA", "RGBA", "geometric", ["type", "4"])
! 
! 
! #tex.shade(256, 256, 0, 3, "RGB", "RGB", "fnoise",
! #          ["turb", "1", "scale", ".3", "freq", "1", "freq2", "100", "df", 
"2", "bias", "0"])
  
  from gfx.libpaper.textures import getCachedTexture
  
- tex = getCachedTexture([256, 256, 0, 4, "RGBA", "RGBA", "geometric", ["type", 
"5"]])
- 
  
  
  
  class TexLabScene:
      def __init__(self):
!         pass
      def key(self, k):
          pass
      def scene(self, vs):
  
        putnoc(vs, background((0.5,0.5,0.5)))
--- 1,57 ----
  # A simple window for testing shaders and adjusting parameters
+ #
+ # Use +/- to change between the libtexture textures listed in args below
+ # or set the global variable tex to some other GL.Texture
+ 
  from __future__ import nested_scopes
  
  import math
  
  #tex = GL.createTexture()
  
! tres = 128
! args = [
!          [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
!                    ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]],
!          [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
!                    ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5",
!                     "seed", "1412"]],
!          [tres, tres, 0, 4, "RGBA", "RGBA", "fnoise",
!                    ["turb", "1", "scale", ".3", "freq", "1",
!                     "freq2", "100", "df", "2", "bias", "0"]],
!          [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "0"]],
!          [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "1"]],
!          [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "2"]],
!          [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "3"]],
!          [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "4"]],
!          [64, 64, 0, 4, "RGBA", "RGBA", "geometric", ["type", "5"]],
!          ]
  
  from gfx.libpaper.textures import getCachedTexture
  
  
  
  
  class TexLabScene:
      def __init__(self):
!         self.ind = 0
!         if not globals().has_key("tex"): self.inittex()
!         
!     def inittex(self):
!         global tex
!         tex = getCachedTexture(args[self.ind])
!     
      def key(self, k):
+         reinit = 0
+         if k == "+": self.ind = (self.ind+1) % len(args); reinit=1
+         if k == "-": self.ind = (self.ind+len(args)-1) % len(args); reinit=1
+ 
+         if reinit:
+             self.inittex()
+             print "Texture", self.ind
+         
          pass
+     
      def scene(self, vs):
  
        putnoc(vs, background((0.5,0.5,0.5)))
***************
*** 39,46 ****
  
        vs.map.put(getDList("""
                BindTexture TEXTURE_2D %s
!                 TexParameter TEXTURE_2D TEXTURE_MAG_FILTER LINEAR
!                 TexParameter TEXTURE_2D TEXTURE_MIN_FILTER 
LINEAR_MIPMAP_LINEAR
                Enable TEXTURE_2D
                  Disable ALPHA_TEST
                  Color 1 1 1
--- 62,69 ----
  
        vs.map.put(getDList("""
                BindTexture TEXTURE_2D %s
!                 TexParameter TEXTURE_2D TEXTURE_MAG_FILTER NEAREST
!                 TexParameter TEXTURE_2D TEXTURE_MIN_FILTER NEAREST
                Enable TEXTURE_2D
                  Disable ALPHA_TEST
                  Color 1 1 1
***************
*** 54,60 ****
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1 0 0
                  Color 1 0 0
                Begin QUAD_STRIP
                    TexCoord 0 0
--- 77,83 ----
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1.1 0 0
                  Color 1 0 0
                Begin QUAD_STRIP
                    TexCoord 0 0
***************
*** 66,72 ****
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1 0 0
                  Color 0 1 0
                Begin QUAD_STRIP
                    TexCoord 0 0
--- 89,95 ----
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1.1 0 0
                  Color 0 1 0
                Begin QUAD_STRIP
                    TexCoord 0 0
***************
*** 78,84 ****
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1 0 0
                  Color 0 0 1
                Begin QUAD_STRIP
                    TexCoord 0 0
--- 101,107 ----
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1.1 0 0
                  Color 0 0 1
                Begin QUAD_STRIP
                    TexCoord 0 0
***************
*** 90,96 ****
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1 0 0
                  Color 0 0 0
                  BlendFunc ZERO SRC_ALPHA
                  Enable BLEND
--- 113,119 ----
                    TexCoord 1 1
                    Vertex 1 1
                End
!                 Translate 1.1 0 0
                  Color 0 0 0
                  BlendFunc ZERO SRC_ALPHA
                  Enable BLEND
Index: gzz/gfx/libpaper/textures.py
diff -c gzz/gfx/libpaper/textures.py:1.18 gzz/gfx/libpaper/textures.py:1.19
*** gzz/gfx/libpaper/textures.py:1.18   Tue Oct  8 11:12:29 2002
--- gzz/gfx/libpaper/textures.py        Tue Oct  8 12:09:54 2002
***************
*** 54,66 ****
  
  
  class NamedTexture:
!     def __init__(self, name, args):
!       print "Generating texture: ",name, args
!         #self.texture = GL.createTexture()
!       #res = self.texture.shade(*args)
!       #print "SHADER: ", res, self.texture.getTexId()
!         self.texture = getCachedTexture(args)
!         self.name = name
      def getTexId(self):
          return self.texture.getTexId()
      def getName(self):
--- 54,68 ----
  
  
  class NamedTexture:
!     def __init__(self, dict):
!         # Add default values below
!         self.continuous = 1
! 
!         # Update from specified values
!         self.__dict__.update(dict)
!         
!       print "Generating texture: ", self.name, self.args
!         self.texture = getCachedTexture(self.args)
      def getTexId(self):
          return self.texture.getTexId()
      def getName(self):
***************
*** 73,95 ****
      global initialized
      initialized = 1
      global ptextures
!     ptextures["RGB2"] = [
!         apply(NamedTexture, i) for i in [
!         ("rgbw1", [tres, tres, 0, 3, "RGB", "RGB",
!                    "fnoise", ["scale", "2.5", "freq", "1", "df", "2", "bias", 
"0.5"]]),
!         ("rgbw2", [tres, tres, 0, 3, "RGB", "RGB",
!                    "fnoise", ["scale", ".43", "freq", "1", "df", "2", "bias", 
"0.5", "seed", "1412"]]),
!         
!         ("turb", [tres, tres, 0, 3, "RGB", "RGB",
!                   "fnoise", ["turb", "1", "scale", ".3", "freq", "1", 
"freq2", "100", "df", "2", "bias", "0"]]),
!         
!         ("pyramid", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "0"]]),
!         ("checkerboard", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", 
"1"]]),
!         ("cone", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "2"]]),
!         ("checkerboard2", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", 
"3"]]),
!         ("saw", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "4"]]),
!         ("triangle", [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", 
"5"]]),
!         ]]
      
  def getPaperTexture(type, gen):
      return selectRandom(ptextures[type], gen)
--- 75,125 ----
      global initialized
      initialized = 1
      global ptextures
!     ptextures["RGB2"] = map(NamedTexture, [
!         {"name" : "rgbw1",
!          "args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
!                    ["scale", "2.5", "freq", "1", "df", "2", "bias", "0.5"]],
!          },
!         
!         {"name" : "rgbw2",
!          "args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
!                    ["scale", ".43", "freq", "1", "df", "2", "bias", "0.5",
!                     "seed", "1412"]],
!          },
!         
!         {"name" : "turb",
!          "args" : [tres, tres, 0, 3, "RGB", "RGB", "fnoise",
!                    ["turb", "1", "scale", ".3", "freq", "1",
!                     "freq2", "100", "df", "2", "bias", "0"]],
!          },
!         
!         {"name" : "pyramid",
!          "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "0"]],
!          },
!         
!         {"name" : "checkerboard",
!          "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "1"]],
!          "continuous" : 0,
!          },
!         
!         {"name" : "cone",
!          "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "2"]],
!          },
!         
!         {"name" : "checkerboard2",
!          "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "3"]],
!          "continuous" : 0,
!          },
!         
!         {"name" : "saw",
!          "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "4"]],
!          "continuous" : 0,
!          },
!         
!         {"name" : "triangle",
!          "args" : [64, 64, 0, 3, "RGB", "RGB", "geometric", ["type", "5"]],
!          },
!         ])
      
  def getPaperTexture(type, gen):
      return selectRandom(ptextures[type], gen)
Index: gzz/gfx/libtexture/geometric.texture
diff -c gzz/gfx/libtexture/geometric.texture:1.2 
gzz/gfx/libtexture/geometric.texture:1.3
*** gzz/gfx/libtexture/geometric.texture:1.2    Tue Oct  8 06:29:52 2002
--- gzz/gfx/libtexture/geometric.texture        Tue Oct  8 12:09:54 2002
***************
*** 18,24 ****
    x -= floor(x);
    y -= floor(y);
  
!   return (x - .5) * (y - .5) < 0;
  }
  
  float cone(float x, float y) {
--- 18,24 ----
    x -= floor(x);
    y -= floor(y);
  
!   return (x < .499999) ^ (y < .499999);
  }
  
  float cone(float x, float y) {
***************
*** 34,40 ****
  float checkerboard2(float x, float y) {
    x -= floor(x);
    y -= floor(y);
!   return x < .5 && y < .5;
  }
  
  float saw(float x) {
--- 34,40 ----
  float checkerboard2(float x, float y) {
    x -= floor(x);
    y -= floor(y);
!   return (x < .499999) && (y < .499999);
  }
  
  float saw(float x) {
***************
*** 56,61 ****
--- 56,62 ----
      float x, y;
      float xstep = 1.0 / width;
      float ystep = 1.0 / height;
+ 
      for (j = 0, y = 0; j < height; j++, y += ystep) { 
        for (i = 0, x = 0; i < width; i++, x += xstep) {
  
***************
*** 86,94 ****
          break;
        case 4:
          if (components >= 1) data[ind++] = saw(x);
!         if (components >= 2) data[ind++] = saw(1 - x);
          if (components >= 3) data[ind++] = saw(y);
!         if (components >= 4) data[ind++] = saw(1 - y);
          break;
        case 5:
          if (components >= 1) data[ind++] = triangle(x);
--- 87,95 ----
          break;
        case 4:
          if (components >= 1) data[ind++] = saw(x);
!         if (components >= 2) data[ind++] = saw(1 - xstep - x);
          if (components >= 3) data[ind++] = saw(y);
!         if (components >= 4) data[ind++] = saw(1 - ystep - y);
          break;
        case 5:
          if (components >= 1) data[ind++] = triangle(x);




reply via email to

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