Class: Roglew::VertexArray

Inherits:
Object
  • Object
show all
Defined in:
lib/roglew/extensions/GL_ARB_vertex_array_object/vertex_array.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handle) ⇒ VertexArray

Returns a new instance of VertexArray.



6
7
8
9
10
# File 'lib/roglew/extensions/GL_ARB_vertex_array_object/vertex_array.rb', line 6

def initialize(handle)
  @handle = handle
  @id = handle.bind { |rc| rc.gen_vertex_arrays }
  ObjectSpace.define_finalizer(self, self.class.finalize(@handle, @id))
end

Instance Attribute Details

#handleObject (readonly)

Returns the value of attribute handle.



4
5
6
# File 'lib/roglew/extensions/GL_ARB_vertex_array_object/vertex_array.rb', line 4

def handle
  @handle
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/roglew/extensions/GL_ARB_vertex_array_object/vertex_array.rb', line 4

def id
  @id
end

Class Method Details

.finalize(handle, id) ⇒ Object



12
13
14
15
16
17
# File 'lib/roglew/extensions/GL_ARB_vertex_array_object/vertex_array.rb', line 12

def self.finalize(handle, id)
  proc do
    #puts "releasing vertex array #{id}"
    handle.bind { |rc| rc.delete_vertex_arrays(id) }
  end
end

Instance Method Details

#bindObject



19
20
21
22
23
24
25
26
# File 'lib/roglew/extensions/GL_ARB_vertex_array_object/vertex_array.rb', line 19

def bind
  @handle.glBindVertexArray(@id)
  if block_given?
    yield
    @handle.glBindVertexArray(0)
  end
  self
end