Class: Budgie::DrawPartial

Inherits:
Object
  • Object
show all
Includes:
GL
Defined in:
lib/budgie/draw_partial.rb

Instance Method Summary collapse

Constructor Details

#initialize(draw_map, x, y, z) ⇒ DrawPartial

Returns a new instance of DrawPartial.



7
8
9
10
11
12
13
14
15
16
# File 'lib/budgie/draw_partial.rb', line 7

def initialize(draw_map, x, y, z)
  @draw_map = draw_map
  @map = draw_map.map
  @size = draw_map.partial_size
  @x = x
  @y = y
  @z = z
  @list = glGenLists 1
  @cube = DrawCube.new
end

Instance Method Details

#compileObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/budgie/draw_partial.rb', line 22

def compile
  dx = @x * @size
  dy = @y * @size
  dz = @z * @size

  glNewList @list, GL_COMPILE
  @size.times do |x|
  @size.times do |y|
  @size.times do |z|
    cx = x + dx
    cy = y + dy
    cz = z + dz
    index = @map[cx, cy, cz]
    cube cx, cy, cz, index if index
  end
  end
  end
  glEndList
end

#drawObject



18
19
20
# File 'lib/budgie/draw_partial.rb', line 18

def draw
  glCallList @list
end