Class: Processing::Shader
- Inherits:
-
Object
- Object
- Processing::Shader
- Includes:
- Xot::Inspectable
- Defined in:
- lib/processing/shader.rb
Overview
Shader object.
Instance Method Summary collapse
-
#initialize(vertSrc, fragSrc) ⇒ Shader
constructor
Initialize shader object.
-
#set(name, *args) ⇒ Object
(also: #setUniform)
Sets uniform variables.
Constructor Details
#initialize(vertSrc, fragSrc) ⇒ Shader
Initialize shader object.
18 19 20 |
# File 'lib/processing/shader.rb', line 18 def initialize(vertSrc, fragSrc) @shader = Rays::Shader.new modifyFragSource__(fragSrc), vertSrc, ENV__ end |
Instance Method Details
#set(name, a) ⇒ Object #set(name, a, b) ⇒ Object #set(name, a, b, c) ⇒ Object #set(name, a, b, c, d) ⇒ Object #set(name, nums) ⇒ Object #set(name, vec) ⇒ Object #set(name, vec, ncoords) ⇒ Object #set(name, tex) ⇒ Object Also known as: setUniform
Sets uniform variables.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/processing/shader.rb', line 46 def set(name, *args) arg = args.first case when Array === arg @shader.uniform name, *arg when Numeric === arg @shader.uniform name, *args when Vector === arg vec, ncoords = args @shader.uniform name, vec.getInternal__.to_a(ncoords || 3) when arg.respond_to?(:getInternal__) @shader.uniform name, arg.getInternal__ else raise ArgumentError end end |