Sha256: 69f93781abb6efbfb52de5ad2d67f3555fe3c29e20a09a469632a9702e7e8968
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../../lib") $:.unshift File.expand_path(File.dirname(__FILE__) + "/../../ext") require 'ray' class CustomSprite < Ray::Drawable def initialize(img) super Ray::Vertex self.vertex_count = 4 self.textured = true @img = img end def fill_vertices rect = @img.tex_rect [0, 0, @img.w, @img.h] [ Ray::Vertex.new([0, 0], Ray::Color.white, rect.top_left), Ray::Vertex.new([@img.w, 0], Ray::Color.white, rect.top_right), Ray::Vertex.new([0, @img.h], Ray::Color.white, rect.bottom_left), Ray::Vertex.new([@img.w, @img.h], Ray::Color.white, rect.bottom_right), ] end def render(first, index) @img.bind Ray::GL.draw_arrays :triangle_strip, first, 4 end end Ray.game "OpenGL textured", :size => [500, 500] do register do add_hook :quit, method(:exit!) end scene :image do image = Ray::Image.new [50, 50] image_target image do |target| target.clear Ray::Color.blue target.draw Ray::Polygon.circle([25, 25], 10, Ray::Color.green) target.update end @sprite = CustomSprite.new image render do |win| win.draw @sprite end end scenes << :image end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ray-0.2.1 | samples/opengl/image.rb |
ray-0.2.0 | samples/opengl/image.rb |