Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Help translating from GLUT to FXRuby??

Reply
Thread Tools

Help translating from GLUT to FXRuby??

 
 
Tom Nakamura
Guest
Posts: n/a
 
      06-16-2005
Can some please help me translate smooth.rb (below) from yoshi's opengl
extension to FXRuby? I've never used opengl before, and am having
trouble translating from GLUT to FXRuby. My poor attempt is also
below...
Tom Nakamura


##
##smooth.rb sample from yoshi's opengl
##shows a pretty little triangle
##
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:ROJECTION)
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;


##
##My rather pathetic attempt to translate above to FXRuby...
##
require 'fox'
require 'opengl'
include Fox

class GLWindow < FXMainWindow
def initialize(app)
super(app, "GLWindow")
@visual = FXGLVisual.new(app, VISUAL_DOUBLEBUFFER)
@canvas = FXGLCanvas.new(self,@visual)
@canvas.connect(SEL_PAINT) do
display
end
FXButton.new(self,"display").connect(SEL_COMMAND) do |sender,
selector, data|
display
end
end

def display
@canvas.makeCurrent()
GL.Viewport(0, 0, @canvas.width, @canvas.height)
GL.ClearColor(1.0,1.0,1.0,1.0)
GL.Clear(GL::COLOR_BUFFER_BIT|GL:EPTH_BUFFER_BIT )
GL.Disable(GL:ITHER)
GL.MatrixMode(GL:ROJECTION)
GL.LoadIdentity
GL.Ortho(0, @canvas.width, 0, @canvas.height, -1, 1)
GL.Scale(1, -1, 1)
GL.Translate(0, http://www.velocityreviews.com/forums/(E-Mail Removed), 0)
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
@canvas.makeCurrent()
end

def create
super
show(PLACEMENT_SCREEN)
end
end

app = FXApp.new
GLWindow.new(app)
app.create
app.run


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GLUT & QT Together Adam Hartshorne C++ 7 04-24-2005 09:45 PM
How do I get GLUT to work with GCC for Win32? Bushido Hacks C++ 0 02-20-2005 04:45 AM
GLUT with another toolbox Fulko van Westrenen Python 0 11-15-2003 08:08 AM
GLUT/Tk problem Fulko van Westrenen Python 1 11-13-2003 04:00 PM
GLUT callback registration (not quite OT) Martin Magnusson C++ 1 09-05-2003 11:33 PM



Advertisments