Class: RBGL::Engine::VertexLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/rbgl/engine/buffer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



99
100
101
# File 'lib/rbgl/engine/buffer.rb', line 99

def attributes
  @attributes
end

#strideObject (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_colorObject



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_uvObject



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_colorObject



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_onlyObject



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