Permalink
Browse files

Keep blocks sorted, only re-sort on change

  • Loading branch information...
Fudge committed Dec 14, 2008
1 parent 2bd8877 commit 4e9be20fab43c2979f8aed849a7bcd3d201f2186
Showing with 2 additions and 3 deletions.
  1. +1 −0 lib/gl_tail/config.rb
  2. +1 −3 lib/gl_tail/engine.rb
View
@@ -123,6 +123,7 @@ def blocks
def add_block(name)
@blocks << b = Block.new(self, name)
+ @blocks.sort! {|k,v| k.order <=> v.order}
b
end
View
@@ -65,9 +65,7 @@ def draw
glEnd()
glPopMatrix()
- # TODO: do we really need to sort every block on every draw?!
- # Nope. But it was a hash, so keeping order was a bit hard.
- @config.blocks.sort { |k,v| k.order <=> v.order}.each do |block|
+ @config.blocks.each do |block|
# glPushMatrix + glTranslate3f to render each element relativ to its containing block instead of the screen?
positions[block.is_right] = block.render(self, positions[block.is_right] || 0 )
end

0 comments on commit 4e9be20

Please sign in to comment.