Module: Rabbit::Renderer::GL

Included in:
Display::GL
Defined in:
lib/rabbit/renderer/gl.rb

Instance Method Summary collapse

Instance Method Details

#draw_cone(filled, x, y, z, base, height, slices, stacks, color = nil, &block) ⇒ Object


40
41
42
43
44
45
46
# File 'lib/rabbit/renderer/gl.rb', line 40

def draw_cone(filled, x, y, z, base, height, slices, stacks,
              color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_cone(filled, base, height, slices, stacks)
  end
end

#draw_cube(filled, x, y, z, size, color = nil, &block) ⇒ Object


25
26
27
28
29
30
# File 'lib/rabbit/renderer/gl.rb', line 25

def draw_cube(filled, x, y, z, size, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_cube(filled, size)
  end
end

#draw_dodecahedron(filled, x, y, z, color = nil, &block) ⇒ Object


71
72
73
74
75
76
# File 'lib/rabbit/renderer/gl.rb', line 71

def draw_dodecahedron(filled, x, y, z, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_dodecahedron(filled)
  end
end

#draw_icosahedron(filled, x, y, z, color = nil, &block) ⇒ Object


78
79
80
81
82
83
# File 'lib/rabbit/renderer/gl.rb', line 78

def draw_icosahedron(filled, x, y, z, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_icosahedron(filled)
  end
end

#draw_octahedron(filled, x, y, z, color = nil, &block) ⇒ Object


64
65
66
67
68
69
# File 'lib/rabbit/renderer/gl.rb', line 64

def draw_octahedron(filled, x, y, z, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_octahedron(filled)
  end
end

#draw_slide(slide, simulation, &block) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rabbit/renderer/gl.rb', line 13

def draw_slide(slide, simulation, &block)
  if gl_available?
    gl_drawable.gl_begin(gl_context) do
      init_gl_drawing_info
      super(slide, simulation, &block)
      gl_drawable.swap_buffers if gl_drawable.double_buffered?
    end
  else
    super(slide, simulation, &block)
  end
end

#draw_sphere(filled, x, y, z, radius, slices, stacks, color = nil, &block) ⇒ Object


32
33
34
35
36
37
38
# File 'lib/rabbit/renderer/gl.rb', line 32

def draw_sphere(filled, x, y, z, radius, slices, stacks,
                color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_sphere(filled, radius, slices, stacks)
  end
end

#draw_teapot(filled, x, y, z, scale, color = nil, &block) ⇒ Object


85
86
87
88
89
90
# File 'lib/rabbit/renderer/gl.rb', line 85

def draw_teapot(filled, x, y, z, scale, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_teapot(filled, scale)
  end
end

#draw_tetrahedron(filled, x, y, z, color = nil, &block) ⇒ Object


57
58
59
60
61
62
# File 'lib/rabbit/renderer/gl.rb', line 57

def draw_tetrahedron(filled, x, y, z, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_tetrahedron(filled)
  end
end

#draw_torus(filled, x, y, z, inner_radius, outer_radius, n_sides, rings, color = nil, &block) ⇒ Object


48
49
50
51
52
53
54
55
# File 'lib/rabbit/renderer/gl.rb', line 48

def draw_torus(filled, x, y, z, inner_radius, outer_radius,
               n_sides, rings, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::Gdk::GL.draw_torus(filled, inner_radius,
                       outer_radius, n_sides, rings)
  end
end

#gl_call_list(id, x, y, z, color = nil, &block) ⇒ Object


99
100
101
102
103
104
# File 'lib/rabbit/renderer/gl.rb', line 99

def gl_call_list(id, x, y, z, color=nil, &block)
  return super unless gl_available?
  draw_gl(x, y, z, color, block) do
    ::GL.CallList(id)
  end
end

#gl_compile(id) ⇒ Object


92
93
94
95
96
97
# File 'lib/rabbit/renderer/gl.rb', line 92

def gl_compile(id)
  return super unless gl_available?
  ::GL.NewList(id, ::GL::COMPILE)
  yield
  ::GL.EndList
end

#gl_supported?Boolean

Returns:

  • (Boolean)

106
107
108
# File 'lib/rabbit/renderer/gl.rb', line 106

def gl_supported?
  (Gtk::GL::BUILD_VERSION <=> [1, 2, 0]) >= 0
end