Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The way I do it (gtkmm / C++ code) is like this:</p> <pre><code>#include &lt;gtkmm.h&gt; #include &lt;gtkglmm.h&gt; class GLWidget : public Gtk::GL::DrawingArea { public: GLWidget(Glib::RefPtr&lt;Gdk::GL::Config&gt; glconfig) : Gtk::GL::DrawingArea(glconfig) {} ~GLWidget() {} virtual bool on_expose_event(GdkEventExpose* event); }; bool GLWidget::on_expose_event(GdkEventExpose* event) { Glib::RefPtr&lt;Gdk::GL::Drawable&gt; d = get_gl_drawable(); d->gl_begin(get_gl_context()); // make this as complex as you need glClear(GL_COLOR_BUFFER_BIT); d->swap_buffers(); d->gl_end(); return true; } int main(int argc, char **argv) { Gtk::Main kit(argc, argv); Gtk::GL::init(argc, argv); Glib::RefPtr&lt;Gtk::Builder&gt; builder = Gtk::Builder::create_from_file("ui.glade"); Gtk::Window* mainWindow; Gtk::Alignment* container; builder->get_widget("mainWindow", mainWindow); builder->get_widget("Box", container); if (mainWindow == NULL || container == NULL) { g_critical("Gtk Builder failed to load mainWindow and/or container !\n"); return -1; } Glib::RefPtr&lt;Gdk::GL::Config&gt; glconfig; glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGBA | Gdk::GL::MODE_DOUBLE); if (!glconfig) glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB); if (!glconfig) { g_critical("Cannot create OpenGL-capable config\n"); return -1; } GLWidget drawingArea(glconfig); drawingArea.set_size_request(640, 480); drawingArea.show(); container->add(drawingArea); kit.run(*mainWindow); return 0; </code></pre> <p>I.e. I'm simply loading a UI that contains an <em>empty</em> container widget, get the handle to that by name, then create the GL-enabled drawing area in code and add it to the empty container. Supposedly, it's possible to "load-time" substitute an ordinary Gtk DrawingArea for a GtkGL one (see <a href="https://stackoverflow.com/questions/1904481/opengl-gtkglextmm-glade">this posting</a>) but that method didn't work for me; the above, programmatically creating it, always did.</p> <p>You need gtkglext / gtkglextmm for the GL Drawingarea widget.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload