Sha256: b2f5a8eac322c168988952dfccbf98b161b0d55c84709da4168bb9128421ffc1
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../../lib") $:.unshift File.expand_path(File.dirname(__FILE__) + "/../../ext") require 'ray' def path_of(res) File.expand_path(res, File.join(File.dirname(__FILE__), '../../test/res')) end class CustomDrawable < Ray::Drawable include Ray::GL def initialize super self.vertex_count = 3 @custom_shader = Ray::Shader.new(:vertex => path_of("vert.c"), :frag => path_of("frag_gray.c")) @custom_shader["in_ModelView"] = Ray::Matrix.identity @custom_shader["in_Projection"] = Ray::Matrix.identity end def fill_vertices [Ray::Vertex.new([0, 0], Ray::Color.red), Ray::Vertex.new([0.5, 0], Ray::Color.green), Ray::Vertex.new([0.5, 0.5], Ray::Color.blue)] end def render(vertex, index) @custom_shader.bind draw_arrays :triangles, vertex, 3 end end Ray.game "OpenGL test" do register do add_hook :quit, method(:exit!) end scene :triangle do @obj = CustomDrawable.new render do |win| win.draw @obj end end scenes << :triangle end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ray-0.2.1 | samples/opengl/shader.rb |
ray-0.2.0 | samples/opengl/shader.rb |