class Roglew::ShaderProgram
Attributes
handle[R]
id[R]
shaders[R]
Public Class Methods
finalize(id, handle)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 15 def self.finalize(id, handle) proc do #puts "releasing program #{id}" handle.bind { handle.glDeleteProgram(id) } end end
new(handle)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 7 def initialize(handle) @handle = handle @id = handle.bind { handle.glCreateProgram() } @attribs, @uniforms = {}, {} ObjectSpace.define_finalizer(self, self.class.finalize(@id, @handle)) end
Public Instance Methods
attach(*shaders)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 22 def attach(*shaders) @shaders = shaders unless shaders.length == 0 @handle.bind { @shaders.each { |shader| @handle.glAttachShader(@id, shader.id) } } nil end
attrib_location(name)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 47 def attrib_location(name) name = name.to_sym loc = @attribs[name] return loc if loc loc = @handle.bind { @handle.glGetAttribLocation(@id, name.to_s) } return nil if loc < 0 @attribs[name] = loc end
attrib_locations(*names)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 56 def attrib_locations(*names) @handle.bind { names.map { |name| attrib_location(name) } } end
link_program()
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 28 def link_program @handle.bind { @handle.glLinkProgram(@id) } raise CompileError, info_log unless link_status end
Also aliased as: link
link_status()
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 33 def link_status @handle.bind { |context| context.get_program(@id, GL::LINK_STATUS) } end
uniform_location(name)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 60 def uniform_location(name) name = name.to_sym loc = @uniforms[name] return loc if loc loc = @handle.bind { @handle.glGetUniformLocation(@id, name.to_s) } return nil if loc < 0 @uniforms[name] = loc end
uniform_locations(*names)
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 69 def uniform_locations(*names) @handle.bind { names.map { |name| uniform_location(name) } } end
use_program() { || ... }
click to toggle source
# File lib/roglew/extensions/GL_VERSION_2_0/shader_program.rb, line 37 def use_program @handle.bind do @handle.glUseProgram(@id) if block_given? yield @handle.glUseProgram(0) end end end
Also aliased as: use