Class: Glslkit::Program

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

Overview

ValidatorとManifest.buildが共有する薄い値オブジェクト(§8.3)。 sourcesはマージ前の Glslkit::Source をそのまま保持する — E006(同一ステージ内の 重複宣言)はマージ後のデータからは検出できないため、生のReflectionへの アクセスが必要になる。

Constant Summary collapse

STAGES =
%i[vertex fragment].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, sources:) ⇒ Program

Returns a new instance of Program.



13
14
15
16
17
18
19
20
# File 'lib/glslkit/program.rb', line 13

def initialize(name:, sources:)
  unless sources.is_a?(Hash) && !sources.empty? && (sources.keys - STAGES).empty?
    raise ArgumentError, "sources must be a non-empty Hash with only :vertex and/or :fragment keys"
  end

  @name = name
  @sources = sources
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/glslkit/program.rb', line 11

def name
  @name
end

#sourcesObject (readonly)

Returns the value of attribute sources.



11
12
13
# File 'lib/glslkit/program.rb', line 11

def sources
  @sources
end

Instance Method Details

#fragmentObject



26
27
28
# File 'lib/glslkit/program.rb', line 26

def fragment
  sources[:fragment]
end

#vertexObject



22
23
24
# File 'lib/glslkit/program.rb', line 22

def vertex
  sources[:vertex]
end