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

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

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

revision 1.1 by tjl, Mon Oct 7 14:18:51 2002 UTC revision 1.2 by tjl, Mon Oct 7 17:47:55 2002 UTC
# Line 1  Line 1 
1    from gfx.libutil import nvcode
2    from gzz.vob import *
3    
4  fonts = [ GL.createFont("gfx/fonts/a010013l.pfb", size)  fonts = [ GL.createFont("gfx/fonts/a010013l.pfb", size)
5      for size in (8, 16, 24, 32, 64) ]      for size in (8, 16, 24, 32, 64) ]
6    
7    textstyle = GLTextStyle.create("sans", 0, 1)
8    
9  A = [GLRen.createHorizText2(f, "ABCgabcg", 1, 1, 1, 0) for f in fonts]  A = [GLRen.createHorizText2(f, "ABCgabcg", 1, 1, 1, 0) for f in fonts]
10    B = [TextVob(textstyle, "ABCgabcg") for f in fonts]
11    
12  class TextScene:  class TextScene:
13      def __init__(self):      def __init__(self):
14          self.fontind = 0          self.fontind = len(A)-1
15          self.offset = [(0,0),(1.5,1.5),(0,1.5),(1.5,0)]          self.offset = [(0,0),(1.5,1.5),(0,1.5),(1.5,0)]
16            self.regcomb = 0
17            
18      def key(self, key):      def key(self, key):
19            if key == "c":
20                self.regcomb = not self.regcomb
21                AbstractUpdateManager.setNoAnimation()
22                AbstractUpdateManager.chg()
23          if key == "+":          if key == "+":
24              self.fontind += 1              self.fontind += 1
25              AbstractUpdateManager.setNoAnimation()              AbstractUpdateManager.setNoAnimation()
# Line 30  class TextScene: Line 40  class TextScene:
40              Enable BLEND              Enable BLEND
41              Disable ALPHA_TEST              Disable ALPHA_TEST
42              Color 0 0 0              Color 0 0 0
43              PushAttrib ENABLE_BIT              PushAttrib ENABLE_BIT TEXTURE_BIT
44          """))          """))
45    
46            if self.regcomb:
47                vs.map.put(getDListNocoords(nvcode.combinercode("""
48                    Enable REGISTER_COMBINERS_NV
49                    CombinerParameterNV NUM_GENERAL_COMBINERS_NV 1
50                    CombinerParameterNV CONSTANT_COLOR0_NV 0 0 0 0.4
51                    CI0 ALPHA A TEXTURE0 UNSIGNED_IDENTITY_NV ALPHA
52                    CI0 ALPHA B CONSTANT_COLOR0_NV UNSIGNED_IDENTITY_NV ALPHA
53                    CO0 ALPHA SPARE0_NV DISCARD_NV DISCARD_NV SCALE_BY_FOUR_NV  NONE FALSE FALSE FALSE
54    
55                    FCI A ZERO UNSIGNED_IDENTITY_NV RGB
56                    FCI B ZERO UNSIGNED_IDENTITY_NV RGB
57                    FCI C ZERO UNSIGNED_IDENTITY_NV RGB
58                    FCI D ZERO UNSIGNED_IDENTITY_NV RGB
59    
60                    FCI G SPARE0_NV UNSIGNED_IDENTITY_NV ALPHA
61                """)))
62    
63          y = 20          y = 20
64          for s in (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100):          sizes = (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100, 200)
65            for s in sizes:
66              y += s              y += s
67              for i in (self.fontind,): # range(0,len(A)):              for i in (self.fontind,): # range(0,len(A)):
68                  vs.put(A[i], str((s,i)), 0 + self.offset[0][0], 150 + self.offset[0][1], y, s, s)                  vs.put(A[i], str((s,i)), 0, 150 + self.offset[0][0], y + self.offset[0][1], s, s)
69    
70          vs.map.put(getDListNocoords("""          vs.map.put(getDListNocoords("""
71              PopAttrib              PopAttrib
72          """))          """))
73    
74        
75            y = 20
76            sizes = (5, 6, 7, 8, 9, 10, 12, 15, 16, 20, 24, 32, 64, 100, 200)
77            for s in sizes:
78                y += s
79                for i in (self.fontind,): # range(0,len(A)):
80                    vs.put(B[i], "B"+str((s,i)), 0, 500 + self.offset[0][0], y + self.offset[0][1], s, s)
81    
82  currentScene = TextScene()  currentScene = TextScene()
83    

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