lib/cyberarm_engine/lib/shader.rb in cyberarm_engine-0.10.0 vs lib/cyberarm_engine/lib/shader.rb in cyberarm_engine-0.10.1
- old
+ new
@@ -1,21 +1,25 @@
module CyberarmEngine
# Ref: https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/OrangeBook/brick.rb
class Shader
include OpenGL
+ @@shaders = {}
def self.add(name, instance)
- @shaders ||= {}
- @shaders[name] = instance
+ @@shaders[name] = instance
end
def self.use(name, &block)
- shader = @shaders.dig(name)
+ shader = @@shaders.dig(name)
if shader
shader.use(&block)
else
raise ArgumentError, "Shader '#{name}' not found!"
end
+ end
+
+ def self.available?(name)
+ @@shaders.dig(name).is_a?(Shader)
end
def self.active_shader
@active_shader
end
\ No newline at end of file