Sha256: 054b0ecb27bab57c94be1ce4260f9c99b4d99eba12ad871c858c5717d1f86ccc

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

$:.unshift File.expand_path(File.dirname(__FILE__) + "/../../lib")
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../../ext")

require 'ray'

class CustomDrawable < Ray::Drawable
  include Ray::GL

  def initialize
    super
    self.vertex_count = 3
  end

  def fill_vertices
     [Ray::Vertex.new([0,  0],  Ray::Color.red),
      Ray::Vertex.new([50, 0],  Ray::Color.green),
      Ray::Vertex.new([50, 50], Ray::Color.blue)]
  end

  def render(vertex, index)
    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
    @obj.pos = window.size / 2

    render do |win|
      win.draw @obj
    end
  end

  scenes << :triangle
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ray-0.2.1 samples/opengl/opengl.rb
ray-0.2.0 samples/opengl/opengl.rb
ray-0.1.1 samples/opengl/opengl.rb
ray-0.1.0 samples/opengl/opengl.rb