Class: Glslkit::WebGL::Geometry

Inherits:
Object
  • Object
show all
Defined in:
lib/glslkit/webgl/geometry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gl, program, attributes:, indices: nil, mode: nil) ⇒ Geometry

Returns a new instance of Geometry.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/glslkit/webgl/geometry.rb', line 8

def initialize(gl, program, attributes:, indices: nil, mode: nil)
  @gl = gl
  @vao = gl.call(:createVertexArray)
  @mode = mode || gl[:TRIANGLES]
  # M11d: 構築時に実際に使ったattributeのlocationを保持する
  # (SPEC-livereload.md §4.2)。reload時、Contextがこれと新Programの
  # locationを突き合わせ、このGeometryのVAOがそのまま使えるかを判断する。
  @attribute_locations = {}
  gl.call(:bindVertexArray, @vao)
  build_attributes(program, attributes)
  build_indices(indices)
  gl.call(:bindVertexArray, JS::Null)
end

Instance Attribute Details

#attribute_locationsObject (readonly)

Returns the value of attribute attribute_locations.



6
7
8
# File 'lib/glslkit/webgl/geometry.rb', line 6

def attribute_locations
  @attribute_locations
end

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/glslkit/webgl/geometry.rb', line 6

def count
  @count
end

#index_typeObject (readonly)

Returns the value of attribute index_type.



6
7
8
# File 'lib/glslkit/webgl/geometry.rb', line 6

def index_type
  @index_type
end

#indexedObject (readonly)

Returns the value of attribute indexed.



6
7
8
# File 'lib/glslkit/webgl/geometry.rb', line 6

def indexed
  @indexed
end

#modeObject (readonly)

Returns the value of attribute mode.



6
7
8
# File 'lib/glslkit/webgl/geometry.rb', line 6

def mode
  @mode
end

#vaoObject (readonly)

Returns the value of attribute vao.



6
7
8
# File 'lib/glslkit/webgl/geometry.rb', line 6

def vao
  @vao
end