gltail 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.1.3 / 2008-03-28
2
+
3
+ * Render strings as number + text to reuse OpenGL call-lists in more cases.
4
+ Fixes the annoying stuttering every second with more than a trivial amount
5
+ of text.
6
+
1
7
  == 0.1.2 / 2008-03-04
2
8
 
3
9
  * Handle rubygems versions > 0.x
@@ -225,31 +225,30 @@ class Element
225
225
  if @rate < 0.0001
226
226
  txt = " r/m "
227
227
  else
228
- txt = "#{sprintf("%7.2f",@rate * 60)} "
228
+ txt = "#{sprintf("%8.2f",@rate * 60)} "
229
229
  end
230
230
  when 1
231
231
  if @total == 0
232
232
  txt = " total "
233
233
  else
234
- txt = "#{sprintf("%7d",@total)} "
234
+ txt = "#{sprintf("%8d",@total)} "
235
235
  end
236
236
  when 2
237
237
  if @average == 0
238
238
  txt = " avg "
239
239
  else
240
- txt = "#{sprintf("%7.2f",@average)} "
240
+ txt = "#{sprintf("%8.2f",@average)} "
241
241
  end
242
242
  else
243
243
  raise "unknown block type #{self.inspect}"
244
244
  end
245
245
 
246
246
  if @x < 0
247
- str = sprintf("%#{@block.width}s %s", @name.length > @block.width ? @name[-@block.width..-1] : @name, txt)
247
+ engine.render_string(sprintf("%#{@block.width}s", @name.length > @block.width ? @name[-@block.width..-1] : @name), txt)
248
248
  else
249
- str = sprintf("%s%s", txt, @name[0..@block.width-1])
249
+ engine.render_string(txt[1..-1], @name[0..@block.width-1])
250
250
  end
251
251
 
252
- engine.render_string(str)
253
252
 
254
253
  glPopMatrix()
255
254
 
@@ -5,8 +5,8 @@ include Glut
5
5
  module GlTail
6
6
  class Engine
7
7
 
8
- def render_string(string)
9
- FontStore.render_string(self, string)
8
+ def render_string(left,right = nil)
9
+ FontStore.render_string(self, left,right)
10
10
  end
11
11
 
12
12
  def screen
@@ -5,6 +5,10 @@ class FontStore
5
5
 
6
6
  @font_texture = nil
7
7
 
8
+ WIDTH = 8 / 256.0
9
+ HEIGHT = 13 / 256.0
10
+
11
+
8
12
  def self.generate_textures
9
13
  if @font_texture.nil?
10
14
  @font_texture = glGenTextures(1)[0]
@@ -112,8 +116,6 @@ class FontStore
112
116
  offsetx = ((base%16) ) / (32.0)
113
117
  offsety = ((base/16) * 16) / (256.0)
114
118
 
115
- width = 8 / 256.0
116
- height = 13 / 256.0
117
119
 
118
120
  pos_offset = char_size * pos
119
121
 
@@ -121,41 +123,58 @@ class FontStore
121
123
  glNormal3f(1.0, 1.0, 0.0)
122
124
  glVertex3f(pos_offset, 0, 0.0)
123
125
 
124
- glTexCoord2f(offsetx+width,offsety)
126
+ glTexCoord2f(offsetx+WIDTH,offsety)
125
127
  glNormal3f(1.0, 1.0, 0.0)
126
128
  glVertex3f(pos_offset + char_size, 0.0, 0.0)
127
129
 
128
- glTexCoord2f(offsetx+width,offsety + height)
130
+ glTexCoord2f(offsetx+WIDTH,offsety + HEIGHT)
129
131
  glNormal3f(1.0, 1.0, 0.0)
130
132
  glVertex3f(pos_offset + char_size, engine.line_size, 0.0)
131
133
 
132
- glTexCoord2f(offsetx,offsety + height)
134
+ glTexCoord2f(offsetx,offsety + HEIGHT)
133
135
  glNormal3f(1.0, 1.0, 0.0)
134
136
  glVertex3f(pos_offset, engine.line_size, 0.0)
135
137
  end
136
138
 
137
139
 
138
- def self.render_string(engine, txt)
140
+ def self.render_string(engine, left, right = nil)
139
141
  glPushMatrix
140
142
  glEnable(GL_BLEND)
141
143
  glBlendFunc(GL_ONE, GL_ONE)
142
144
  glBindTexture(GL_TEXTURE_2D, @font_texture)
143
145
 
144
- unless BlobStore.has(txt)
146
+ pos = 0
147
+
148
+ unless BlobStore.has(left)
145
149
  list = glGenLists(1)
146
150
  glNewList(list, GL_COMPILE)
147
151
  glBegin(GL_QUADS)
148
- pos = 0
149
- txt.each_byte do |c|
152
+ left.each_byte do |c|
153
+ self.render_char(engine, c, pos) unless c == 32
154
+ pos += 1
155
+ end
156
+ glEnd
157
+ glEndList
158
+ BlobStore.put(left,list)
159
+ else
160
+ pos += left.length
161
+ end
162
+ glCallList(BlobStore.get(left))
163
+
164
+ unless BlobStore.has(right) || right.nil?
165
+ list = glGenLists(1)
166
+ glNewList(list, GL_COMPILE)
167
+ glBegin(GL_QUADS)
168
+ right.each_byte do |c|
150
169
  self.render_char(engine, c, pos)
151
170
  pos += 1
152
171
  end
153
172
  glEnd
154
173
  glEndList
155
- BlobStore.put(txt,list)
174
+ BlobStore.put(right,list)
156
175
  end
157
- glCallList(BlobStore.get(txt))
158
-
176
+ glCallList(BlobStore.get(right)) unless right.nil?
177
+
159
178
  glBindTexture(GL_TEXTURE_2D, 0)
160
179
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
161
180
  glDisable(GL_BLEND)
data/lib/gl_tail.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module GlTail
8
- VERSION = '0.1.2'
8
+ VERSION = '0.1.3'
9
9
  end
10
10
 
11
11
  begin
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gltail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ""
6
6
  authors:
7
7
  - Erlend Simonsen
@@ -29,7 +29,7 @@ cert_chain:
29
29
  /UfNqVgtDGy57Xw9DBNRbUm92FVILwpudQs3SX1z2Gik08RrKReELwpRciY=
30
30
  -----END CERTIFICATE-----
31
31
 
32
- date: 2008-03-04 00:00:00 +01:00
32
+ date: 2008-03-28 00:00:00 +01:00
33
33
  default_executable:
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file