# File gtkglext/sample/gtkglut.rb, line 71 def GLUT.CreateWindow(name = "gtkglext") # Top-level window @@window = Gtk::Window.new # Perform the resize immediately @@window.resize_mode = Gtk::RESIZE_IMMEDIATE # Get automatically redrawn if any of their children # changed allocation. @@window.reallocate_redraws = true @@window.signal_connect("delete_event") do Gtk.main_quit true end @@window.title = name @@window.set_events(@@window.events | Gdk::Event::BUTTON_MOTION_MASK | Gdk::Event::POINTER_MOTION_HINT_MASK | Gdk::Event::BUTTON_PRESS_MASK) # VBox vbox = Gtk::VBox.new @@window.add(vbox) vbox.show # Drawing area for drawing OpenGL scene @@drawing_area = Gtk::DrawingArea.new # Set OpenGL-capability to the widget @@drawing_area.set_gl_capability(@@glconfig) vbox.pack_start(@@drawing_area) @@drawing_area.show # The following is a big hack! # Do not do it in a Ruby/GtkGKExt program! # As with GLUT the OpenGL initializations are done between a # CreateWindow and a MainLoop, we must show the window (or else, # we can't get the context) and do a gl_begin. # In a real Ruby/GtkGLExt program, the OpenGL initialization stuff # should be in a signal_connect_after("realize") event callback, # which is called for the first display of the window, # during a window.show (and not after the window.show as I do here) @@window.show glcontext = @@drawing_area.gl_context gldrawable = @@drawing_area.gl_drawable raise "cannot activate OpenGL" if !gldrawable.gl_begin(glcontext) end