From: "Lyle Johnson" <ljohnson / resgen.com>
Subject: [ruby-talk:24600] Re: OpenGL (rbogl) bindings to Tk?
Date: Thu, 8 Nov 2001 06:42:50 +0900
Message-ID: <tuj9l2k08vnrc5 / corp.supernews.com>
> FXRuby, specifically its FXGLViewer and FXGLObject classes for OpenGL. The

Well, the other idea is Tk frame widget(container) ==> 
Ruby/SDL ==> OpenGL. :-)
A few monthes ago, I tried to work Ruby/SDL on a Tk frame widget. 
I used SDL-1.2.1 and rubysdl-0.6 for the experiment.
The following list is tk_sdl.rb to start a Ruby/SDL window 
in a Tk frame widget. 

======================================================
require 'tk'
require 'sdl'

class << SDL
  def run_on_tk(frame = TkFrame.new(nil, 'container'=>true))
    if frame.container == 0
      raise RuntimeError, "TkFrame is NOT a container widget."
    end
    @tk_frame = frame
  end

  alias original_SDL_init init
  def init(*args)
    Tk.update
    unless TkWinfo.mapped? @tk_frame
      raise RuntimeError, "Base window is NOT mapped on the display."
    end
    ENV['SDL_WINDOWID'] = TkWinfo.id(@tk_frame)
    original_SDL_init(*args)
  end

  alias original_SDL_setVideoMode setVideoMode
  def setVideoMode(width, height, depth, *param)
    @tk_frame.configure('width'=>width, 'height'=>height)
    Tk.update
    original_SDL_setVideoMode(width, height, depth, *param)
  end
end
======================================================

And, the following is a sample to run movesp.rb in a Tk frame widget. 
( movesp.rb is a Ruby/SDL sample script destributed with Ruby/SDL. )

======================================================
require 'tk_sdl'

TkButton.new(nil, 'text'=>'EXIT', 
             'command'=>proc{exit}).pack('fill'=>'x')
frame = SDL.run_on_tk.pack
frame.bind('Button-1', 
           proc{|x,y| print "clicked at (#{x},#{y})!!\n"}, '%x %y')
Thread.new{Tk.mainloop}

load 'movesp.rb'
======================================================

That is all. No need to edit the Ruby/Tk script.  :-)
In this sample script, I do binding to the SDL frame.
It's available. 
If you click the left button of your mouse on the SDL frame, 
you will get some output about coordinates of clicked position. 
-- 
                                  Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)