Class: Gl::VertexArray

Inherits:
GlInternalMarked show all
Defined in:
lib/opengl-core/aux/vertex_array.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GlInternalMarked

#==, #__mark__, __marked_allocated__, #__unmark__, allocated, clear_all, delete_all, inherited, #marked?

Constructor Details

#initialize(name = nil) ⇒ VertexArray

Returns a new instance of VertexArray.



8
9
10
11
12
# File 'lib/opengl-core/aux/vertex_array.rb', line 8

def initialize(name = nil)
  super()
  @name = name || 0
  __mark__ if @name != 0
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/opengl-core/aux/vertex_array.rb', line 6

def name
  @name
end

Class Method Details

.unbindObject



38
39
40
41
# File 'lib/opengl-core/aux/vertex_array.rb', line 38

def self.unbind
  Gl.glBindVertexArray(0)
  self
end

Instance Method Details

#bindObject



23
24
25
26
27
28
29
30
31
# File 'lib/opengl-core/aux/vertex_array.rb', line 23

def bind
  if @name == 0
    @name = Gl.glGenVertexArrays(1)[0]
    __mark__
  end

  Gl.glBindVertexArray(@name)
  self
end

#deleteObject



14
15
16
17
18
19
20
21
# File 'lib/opengl-core/aux/vertex_array.rb', line 14

def delete
  if @name != 0
    Gl.glDeleteVertexArrays(@name)
    @name = 0
    super
  end
  self
end

#unbindObject



33
34
35
36
# File 'lib/opengl-core/aux/vertex_array.rb', line 33

def unbind
  self.class.unbind
  self
end