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

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

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

revision 1.1 by tjl, Fri Jan 17 14:38:39 2003 UTC revision 1.2 by tjl, Fri Jan 17 15:06:37 2003 UTC
# Line 11  import math Line 11  import math
11  from gfx.util.misc import *  from gfx.util.misc import *
12  from gzz.gfx.gl import MipzipLoader, MipzipMemoryConsumer  from gzz.gfx.gl import MipzipLoader, MipzipMemoryConsumer
13  from gzz.mem import MemoryPartitioner  from gzz.mem import MemoryPartitioner
14    from gzz.client import AbstractUpdateManager
15    
16  class Scene:  class Scene:
17      def __init__(self):      def __init__(self):
18          self.mem = MemoryPartitioner(16 * 1024 * 1024)          self.mem = MemoryPartitioner(4 * 1024 * 1024)
19          self.files = []          self.files = []
20          for f in glob.glob("../mstmpimg/*.mipzip"):          self.tex = []
21            for f in glob.glob("../mstmpimg/*.mipzip")[0:5]:
22              ml = MipzipLoader(File(f))              ml = MipzipLoader(File(f))
23              mc = MipzipMemoryConsumer(ml)              mc = MipzipMemoryConsumer(self.mem, ml)
24              self.files.append(mc)              self.files.append(mc)
25              self.tex.append(getDListNocoords("""              self.tex.append(getDListNocoords("""
26                  BindTexture TEXTURE_2D %s                  BindTexture TEXTURE_2D %s
# Line 26  class Scene: Line 28  class Scene:
28          self.nrows = int(math.sqrt(len(self.files))) + 1          self.nrows = int(math.sqrt(len(self.files))) + 1
29          self.x = 512          self.x = 512
30          self.y = 384          self.y = 384
31          self.quad = getDListNocoords("""          self.quad = getDList("""
32              Enable TEXTURE_2D              Enable TEXTURE_2D
33                Color 1 1 1 1
34              Begin QUADS              Begin QUADS
35              TexCoord %(x0)s %(y0)s              TexCoord %(x0)s %(y0)s
36              Vertex 0 0              Vertex 0 0
# Line 41  class Scene: Line 44  class Scene:
44          """ % { "x0" : .3, "y0" : .3, "x1": .35, "y1":.35 })          """ % { "x0" : .3, "y0" : .3, "x1": .35, "y1":.35 })
45      def scene(self, vs):      def scene(self, vs):
46          vs.map.put(background((.3,.7,.8)))          vs.map.put(background((.3,.7,.8)))
47            AbstractUpdateManager.setNoAnimation()
48          w = vs.size.width / self.nrows          w = vs.size.width / self.nrows
49          h = vs.size.height / self.nrows          h = vs.size.height / self.nrows
50            # print "Sc:",len(self.files)
51          for x in range(0, self.nrows):          for x in range(0, self.nrows):
52              for y in range(0, self.nrows):              for y in range(0, self.nrows):
53                  i = x + y * self.nrows                  i = x + y * self.nrows
54                  if i >= self.files.len:                  if i >= len(self.files):
55                      return                      continue
56                  xc = x * w                  xc = x * w
57                  yc = y * w                  yc = y * h
58                                    
59                  imp = 1 / (.1 + math.hypot(self.x - xc, self.y - yc))                  imp = 1 / (.1 + math.hypot(self.x - xc, self.y - yc))
60                  self.files[i].getTexture(imp, 1000)                  self.files[i].getTexture(imp, 4000)
61    
62                  vs.orthoCS(0, str((x,y)), 0, xc, yc, w, h)                  cs = vs.orthoCS(0, str((x,y)), 0, xc, yc, w, h)
63                    vs.map.put(self.tex[i])
64                    vs.map.put(self.quad, cs)
65    
66    
67      def mouse(self, ev):      def mouse(self, ev):
# Line 62  class Scene: Line 69  class Scene:
69          self.y = ev.getY()          self.y = ev.getY()
70          print self.x, self.y          print self.x, self.y
71                    
72        def key(self, key):
73            return

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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