Class: Mittsu::OpenGLProgram

Inherits:
Object
  • Object
show all
Defined in:
lib/mittsu/renderers/opengl/opengl_program.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(renderer, code, material, parameters) ⇒ OpenGLProgram

Returns a new instance of OpenGLProgram.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 9

def initialize(renderer, code, material, parameters)
  @id = (@@id ||= 1).tap { @@id += 1 }
  @renderer = renderer

  compile_and_link_program(material, parameters)

  cache_uniform_locations(material.shader[:uniforms] || {}, parameters)
  cache_attribute_locations(material.attributes || {}, parameters)

  @code = code
  @used_times = 2
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



7
8
9
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 7

def attributes
  @attributes
end

#codeObject

Returns the value of attribute code.



7
8
9
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 7

def code
  @code
end

#fragment_shaderObject

Returns the value of attribute fragment_shader.



7
8
9
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 7

def fragment_shader
  @fragment_shader
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 6

def id
  @id
end

#programObject (readonly)

Returns the value of attribute program.



6
7
8
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 6

def program
  @program
end

#uniformsObject (readonly)

Returns the value of attribute uniforms.



6
7
8
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 6

def uniforms
  @uniforms
end

#used_timesObject

Returns the value of attribute used_times.



7
8
9
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 7

def used_times
  @used_times
end

#vertex_shaderObject

Returns the value of attribute vertex_shader.



7
8
9
# File 'lib/mittsu/renderers/opengl/opengl_program.rb', line 7

def vertex_shader
  @vertex_shader
end