Class: Geom::GluTesselator

Inherits:
Object
  • Object
show all
Includes:
Gl, Glu, Glut
Defined in:
lib/geom/glu_tess.rb

Class Method Summary collapse

Class Method Details

.triangulate(poly) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/geom/glu_tess.rb', line 6

def self.triangulate(poly)
  result = Array.new

  t = gluNewTess
  gluTessCallback(t,GLU_TESS_VERTEX,method(:vertex_callback).to_proc)
  gluTessCallback(t,GLU_TESS_BEGIN,method(:begin_callback).to_proc)
  gluTessCallback(t,GLU_TESS_EDGE_FLAG,proc{})
  gluTessBeginPolygon(t,self)
  gluTessBeginContour(t)

  poly.vertices.each_with_index do |v,i|
    gluTessVertex(t,[v.x,v.y,v.z],v)
  end

  gluTessEndContour(t)
  gluTessEndPolygon(t)
end