Class: RBGL::Engine::VertexLayout
- Inherits:
-
Object
- Object
- RBGL::Engine::VertexLayout
- Defined in:
- lib/rbgl/engine/buffer.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#stride ⇒ Object
readonly
Returns the value of attribute stride.
Class Method Summary collapse
- .position_color ⇒ Object
- .position_normal_uv ⇒ Object
- .position_normal_uv_color ⇒ Object
- .position_only ⇒ Object
Instance Method Summary collapse
- #attribute(name, size, kind: nil) ⇒ Object
-
#initialize(&block) ⇒ VertexLayout
constructor
A new instance of VertexLayout.
Constructor Details
#initialize(&block) ⇒ VertexLayout
Returns a new instance of VertexLayout.
101 102 103 104 105 106 |
# File 'lib/rbgl/engine/buffer.rb', line 101 def initialize(&block) @attributes = {} @offset = 0 instance_eval(&block) if block_given? @stride = @offset end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
99 100 101 |
# File 'lib/rbgl/engine/buffer.rb', line 99 def attributes @attributes end |
#stride ⇒ Object (readonly)
Returns the value of attribute stride.
99 100 101 |
# File 'lib/rbgl/engine/buffer.rb', line 99 def stride @stride end |
Class Method Details
.position_color ⇒ Object
117 118 119 120 121 122 |
# File 'lib/rbgl/engine/buffer.rb', line 117 def self.position_color new do attribute :position, 3 attribute :color, 4 end end |
.position_normal_uv ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/rbgl/engine/buffer.rb', line 124 def self.position_normal_uv new do attribute :position, 3 attribute :normal, 3 attribute :uv, 2 end end |
.position_normal_uv_color ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/rbgl/engine/buffer.rb', line 132 def self.position_normal_uv_color new do attribute :position, 3 attribute :normal, 3 attribute :uv, 2 attribute :color, 4 end end |
.position_only ⇒ Object
113 114 115 |
# File 'lib/rbgl/engine/buffer.rb', line 113 def self.position_only new { attribute :position, 3 } end |
Instance Method Details
#attribute(name, size, kind: nil) ⇒ Object
108 109 110 111 |
# File 'lib/rbgl/engine/buffer.rb', line 108 def attribute(name, size, kind: nil) @attributes[name.to_sym] = VertexAttribute.new(name, size, @offset, kind: kind) @offset += size end |