File: smooth.rb

package info (click to toggle)
libopengl-ruby 0.32f-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 640 kB
  • ctags: 595
  • sloc: ansic: 7,323; ruby: 3,966; makefile: 64
file content (32 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/local/bin/ruby
require "opengl"
require "glut"

STDOUT.sync=TRUE
disp = Proc.new {
  GL.Clear(GL::COLOR_BUFFER_BIT)
  GL.Begin(GL::TRIANGLES)
    GL.Color(0.0, 0.0, 1.0)
    GL.Vertex(0, 0)
    GL.Color(0.0, 1.0, 0.0)
    GL.Vertex(200, 200)
    GL.Color(1.0, 0.0, 0.0)
    GL.Vertex(20, 200)
  GL.End
  GL.Flush
}

reshape = Proc.new {|w, h|
  GL.Viewport(0, 0, w, h)
  GL.MatrixMode(GL::PROJECTION)
  GL.LoadIdentity
  GL.Ortho(0, w, 0, h, -1, 1)
  GL.Scale(1, -1, 1)
  GL.Translate(0, -h, 0)
}

GLUT.Init
a =  GLUT.CreateWindow("single triangle");
GLUT.DisplayFunc(disp);
GLUT.ReshapeFunc(reshape);
GLUT.MainLoop;