From: Ilmari Heikkinen Date: 2005-05-17T21:47:25+09:00 Subject: Ruby/SDL on OSX, part 2 Was surfing the internets today, in search for workable SDL solutions for OSX. And here's two: This one's a wrapper for executing Ruby. It links the SDL libraries and ruby and makes an executable - rsdl, which can then be used to run Ruby/SDL scripts on OSX. This works very well, but since it uses a custom executable, you'd pretty much need to bundle the exe with your app. http://www.kumaryu.net/hiki.cgi?%28Ruby%29+Ruby%2FSDL%CD%D1ruby The second way is to use Ruby/Cocoa, which lets you create an SDL window on OSX. It spews out a metric ton of error messages but seems to work, sans input events :I Wonder if there's any way to make it work better. # Ruby/Cocoa + Ruby/SDL + OpenGL # hello_sdl.rb # def osx? PLATFORM =~ /darwin/ end require 'osx/cocoa' if osx? require 'sdl' require 'opengl' require 'glut' if $0 == __FILE__ then app = OSX::NSApplication.sharedApplication() if osx? SDL.init SDL::INIT_VIDEO SDL.setGLAttr SDL::GL_DOUBLEBUFFER, 1 SDL.setVideoMode 640, 480, 32, SDL::OPENGL SDL::WM.setCaption "Hello SDL & OpenGL", "" GL.ClearColor(0,0,0,0) GL.Enable(GL::DEPTH_TEST) GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT) GL.MatrixMode(GL::PROJECTION) GL.Enable(GL::LIGHTING) GL.Enable(GL::LIGHT0) GL.Light(GL::LIGHT0, GL::POSITION, [2,3,4,1]) GL.LoadIdentity() GLU.Perspective 60, 1.3, 0.1, 100 GL.MatrixMode(GL::MODELVIEW) GL.LoadIdentity() GLU.LookAt(2,2,2 , 0,0,0, 0,1,0) GLUT.SolidCube(1) SDL.GLSwapBuffers() loop{ e = SDL::Event2.poll case e when SDL::Event2::KeyUp break if e.sym == ?q or e.sym == 27 when SDL::Event2::Quit break end } end HTH, Ilmari