Hi,
From: “anne001” [email protected]
class Node
Any option?
I have a very simplistic Ruby wrapper for GLUT… It’s small so
I’ve attached it to this email.
You can subclass GLUTWindow, and just override the methods you
want to add custom handlers for, for ex. reshape_func, keyboard_func,
display_func, draw_scene. This example just overrides draw_scene…
require ‘opengl’
require ‘glut’
require ‘ftgl’
case RUBY_PLATFORM
when /mswin32/
DEFAULT_FONT = “C:/WINNT/Fonts/arial.ttf”
when /darwin/
DEFAULT_FONT = “./demo/arial.ttf” # ???
else
DEFAULT_FONT = “/usr/share/fonts/truetype/arial.ttf”
end
class MyWindow < GLUTWindow
def initialize(left, top, wid, hgt, title, parent=nil)
super
font_filename = DEFAULT_FONT
@font = FTGL::PixmapFont.new(font_filename)
font_size = 24
@font.SetFaceSize(font_size)
end
def draw_scene
super # GLUTWindow#draw_scene will clear the screen for us
GL.PolygonMode(GL::FRONT_AND_BACK, GL::FILL)
GL.RasterPos(100, 50)
@font.Render("hello world")
end
end
GLUT.Init
GLUT.InitDisplayMode(GLUT::DOUBLE | GLUT::RGB)
w = MyWindow.new(100, 100, 800, 600, “hello”)
GLUT.MainLoop
The above example uses the ‘ftgl’ true-type-font extension[1], but
that’s not required to use the GLUTWindow wrapper itself.
Hope this helps,
Bill
[1] http://rubyforge.org/projects/ruby-ftgl/