File: font-glut.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 (39 lines) | stat: -rwxr-xr-x 930 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
33
34
35
36
37
38
39
require "opengl"
require "glut"

display = Proc.new {
   GL::Clear(GL::COLOR_BUFFER_BIT);
   GL.LoadIdentity

   GL::RasterPos2d(20,20)
   "Hello Bitmap".each_byte { |x| GLUT.BitmapCharacter(GLUT::BITMAP_9_BY_15, x) }

   GL.Translate(0, 50, 0)
   GL.Scale(0.25, 0.25, 1)
   "Hello Stroke".each_byte { |x| GLUT.StrokeCharacter(GLUT::STROKE_ROMAN, x) }

   GL.Flush();
}

reshape = Proc.new {|w, h|
   GL::Viewport(0, 0,  w,  h);
   GL::MatrixMode(GL::PROJECTION);
   GL::LoadIdentity();
   GL::Ortho(0.0, w, 0.0, h, -1.0, 1.0);
   GL::MatrixMode(GL::MODELVIEW);
}


#  Main Loop
#  Open window with initial window size, title bar, 
#  color index display mode, and handle input events.
#
   GLUT.Init
   GLUT.InitDisplayMode(GLUT::SINGLE | GLUT::RGB);
   GLUT.InitWindowSize(200, 200);
   GLUT.CreateWindow($0);

   GLUT.ReshapeFunc(reshape);
   GLUT.DisplayFunc(display);
   GLUT.MainLoop