Class: GL::VertexArray
- Inherits:
-
Object
- Object
- GL::VertexArray
- Defined in:
- lib/opengl-aux/vertex_array.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #bind ⇒ Object
- #delete ⇒ Object
-
#initialize(name = nil) {|_self| ... } ⇒ VertexArray
constructor
A new instance of VertexArray.
- #is_vertex_array? ⇒ Boolean
Constructor Details
#initialize(name = nil) {|_self| ... } ⇒ VertexArray
Returns a new instance of VertexArray
37 38 39 40 |
# File 'lib/opengl-aux/vertex_array.rb', line 37 def initialize(name = nil) @name = name || 0 yield self if block_given? end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
35 36 37 |
# File 'lib/opengl-aux/vertex_array.rb', line 35 def name @name end |
Class Method Details
.current_binding ⇒ Object
18 19 20 |
# File 'lib/opengl-aux/vertex_array.rb', line 18 def current_binding GL.glGetInteger(GL::GL_VERTEX_ARRAY_BINDING) end |
.preserve_binding ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/opengl-aux/vertex_array.rb', line 22 def preserve_binding raise ArgumentError, "No block given" unless block_given? binding = current_binding begin yield ensure GL.glBindVertexArray(binding) end end |
Instance Method Details
#bind ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/opengl-aux/vertex_array.rb', line 54 def bind if block_given? self.class.preserve_binding do bind yield self end else if @name == 0 @name = GL.glGenVertexArrays(1) if @name == 0 raise GL::GLCreateError, "Unable to allocate vertex array object" end end GL.glBindVertexArray(@name) self end end |
#delete ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/opengl-aux/vertex_array.rb', line 42 def delete if @name != 0 GL.glDeleteVertexArrays(@name) @name = 0 end self end |
#is_vertex_array? ⇒ Boolean
50 51 52 |
# File 'lib/opengl-aux/vertex_array.rb', line 50 def is_vertex_array? GL::glIsVertexArray(@name) != GL::GL_FALSE end |