Class: RLSL::ShaderBuilder::ShaderDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/rlsl/shader_builder/shader_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uniforms: {}, custom_functions: {}, helpers_block: nil, helpers_mode: :c, fragment_block: nil, fragment_mode: :c) ⇒ ShaderDefinition

Returns a new instance of ShaderDefinition.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 8

def initialize(
  uniforms: {},
  custom_functions: {},
  helpers_block: nil,
  helpers_mode: :c,
  fragment_block: nil,
  fragment_mode: :c
)
  @uniforms = normalize_hash(uniforms)
  @custom_functions = normalize_hash(custom_functions)
  @helpers_block = helpers_block
  @helpers_mode = helpers_mode
  @fragment_block = fragment_block
  @fragment_mode = fragment_mode
end

Instance Attribute Details

#custom_functionsObject (readonly)

Returns the value of attribute custom_functions.



6
7
8
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 6

def custom_functions
  @custom_functions
end

#fragment_blockObject (readonly)

Returns the value of attribute fragment_block.



6
7
8
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 6

def fragment_block
  @fragment_block
end

#fragment_modeObject (readonly)

Returns the value of attribute fragment_mode.



6
7
8
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 6

def fragment_mode
  @fragment_mode
end

#helpers_blockObject (readonly)

Returns the value of attribute helpers_block.



6
7
8
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 6

def helpers_block
  @helpers_block
end

#helpers_modeObject (readonly)

Returns the value of attribute helpers_mode.



6
7
8
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 6

def helpers_mode
  @helpers_mode
end

#uniformsObject (readonly)

Returns the value of attribute uniforms.



6
7
8
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 6

def uniforms
  @uniforms
end

Instance Method Details

#ruby_fragment?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 40

def ruby_fragment?
  @fragment_mode == :ruby
end

#ruby_helpers?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 44

def ruby_helpers?
  @helpers_mode == :ruby
end

#with_custom_functions(custom_functions) ⇒ Object



28
29
30
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 28

def with_custom_functions(custom_functions)
  copy(custom_functions: custom_functions)
end

#with_fragment(mode:, block:) ⇒ Object



36
37
38
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 36

def with_fragment(mode:, block:)
  copy(fragment_mode: mode, fragment_block: block)
end

#with_helpers(mode:, block:) ⇒ Object



32
33
34
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 32

def with_helpers(mode:, block:)
  copy(helpers_mode: mode, helpers_block: block)
end

#with_uniforms(uniforms) ⇒ Object



24
25
26
# File 'lib/rlsl/shader_builder/shader_definition.rb', line 24

def with_uniforms(uniforms)
  copy(uniforms: uniforms)
end