Class: Rugl::Resources::Elements
- Defined in:
- lib/rugl/resources/elements.rb
Instance Attribute Summary collapse
-
#byte_length ⇒ Object
readonly
Returns the value of attribute byte_length.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#primitive ⇒ Object
readonly
Returns the value of attribute primitive.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Attributes inherited from Base
Instance Method Summary collapse
- #bind ⇒ Object
- #destroy ⇒ Object
- #gl_type ⇒ Object
-
#initialize(context, source) ⇒ Elements
constructor
A new instance of Elements.
- #subdata(data, offset: 0) ⇒ Object
- #update(data:) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(context, source) ⇒ Elements
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rugl/resources/elements.rb', line 8 def initialize(context, source) super(context) @target = gl_const(:ELEMENT_ARRAY_BUFFER) @usage = :static @type = :uint16 @primitive = :triangles @length = 0 @count = 0 @byte_length = 0 @id = allocate_gl_id(:GenBuffers) bind payload, index_count, byte_size = normalize_source(source) upload(payload, byte_size) @length = index_count @count = index_count @byte_length = byte_size end |
Instance Attribute Details
#byte_length ⇒ Object (readonly)
Returns the value of attribute byte_length.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def byte_length @byte_length end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def count @count end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def length @length end |
#primitive ⇒ Object (readonly)
Returns the value of attribute primitive.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def primitive @primitive end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def target @target end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def type @type end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
6 7 8 |
# File 'lib/rugl/resources/elements.rb', line 6 def usage @usage end |
Instance Method Details
#bind ⇒ Object
27 28 29 30 31 |
# File 'lib/rugl/resources/elements.rb', line 27 def bind ensure_alive! gl_call(:BindBuffer, @target, @id) if gl_supports?(:BindBuffer) self end |
#destroy ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/rugl/resources/elements.rb', line 54 def destroy return if destroyed? delete_gl_id(:DeleteBuffers, @id) mark_destroyed! nil end |
#gl_type ⇒ Object
62 63 64 |
# File 'lib/rugl/resources/elements.rb', line 62 def gl_type Util.to_gl_buffer_type(@type, gl: gl) end |
#subdata(data, offset: 0) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/rugl/resources/elements.rb', line 46 def subdata(data, offset: 0) ensure_alive! payload, _count, byte_size = normalize_indices(data) gl_call(:BufferSubData, @target, offset.to_i, byte_size, payload) self end |
#update(data:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rugl/resources/elements.rb', line 33 def update(data:) ensure_alive! bind payload, index_count, byte_size = normalize_indices(data) upload(payload, byte_size) @length = index_count @count = index_count @byte_length = byte_size self end |