lib/rubysketch/glsl.rb in rubysketch-0.3.20 vs lib/rubysketch/glsl.rb in rubysketch-0.3.21

- old
+ new

@@ -1,30 +1,37 @@ module RubySketch - # @private - class GLSL + # OpenGL Shader Language + # + module GLSL - def initialize(glsl) - @shader = Reflex::Shader.new glsl - end # @private - def on_start__(window) - start = Time.now.to_f + class Context - window.draw = proc do |e, painter| - painter.paint do |p| - c = window.canvas - w = c.width - h = c.height - t = Time.now.to_f - start - p.shader @shader, resolution: [w, h], time: t if @shader + # @private + def initialize(window, shader_source) + shader = Rays::Shader.new shader_source + start = now__ + window.draw = proc do |e| + i, p = window.canvas_image, window.canvas_painter + w, h = i.width, i.height + p.shader shader, resolution: [w, h], time: now__ - start p.fill 1 p.rect 0, 0, w, h end end - end + + private + + # @private + def now__() + Time.now.to_f + end + + end# Context + end# GLSL end# RubySketch