First of all libglade is an old library. If you are writing new project start with gtk builder.
As you can see here gtkmm provide easy way to create your own widgets and see them (almost) in glade tool. You simply insert plain DrawinArea widget to window and then tell gtk-builder to put in this place yours derived class.
Here is all together:
Setting up gtk-builder:
refBuilder = Gtk::Builder::create_from_file(ui_file);
GlDrawingArea*glArea = NULL;
refBuilder->get_widget_derived("drawing_gl",glArea);
Opengl DrawingArea class:
class GlDrawingArea : public Gtk::DrawingArea ,
public Gtk::GL::Widget<GlDrawingArea>
{
public:
GlDrawingArea(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
virtual ~GlDrawingArea();
protected:
void on_realize();
bool on_expose_event(GdkEventExpose* event);
bool on_configure_event(GdkEventConfigure* event);
private:
Glib::RefPtr<Gtk::Builder> refBuilder;
};
Constructing opengl drawingarea:
// GlDrawingArea:
GlDrawingArea::GlDrawingArea(BaseObjectType*cobject, const Glib::RefPtr<Gtk::Builder>& builder)
: Gtk::DrawingArea(cobject),
refBuilder(builder),
screen_tex(0)
{
//
// Configure OpenGL-capable visual.
//
Glib::RefPtr<Gdk::GL::Config> glconfig;
// Try double-buffered visual
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB |
Gdk::GL::MODE_DEPTH |
Gdk::GL::MODE_DOUBLE);
if (!glconfig) {
std::cerr << "*** Cannot find the double-buffered visual.\n"
<< "*** Trying single-buffered visual.\n";
// Try single-buffered visual
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB |Gdk::GL::MODE_DEPTH);
if (!glconfig) {
std::cerr << "*** Cannot find any OpenGL-capable visual.\n";
std::exit(1);
}
}
// print frame buffer attributes.
GLConfigUtil::examine_gl_attrib(glconfig);
//
// Set OpenGL-capability to the widget.
//
set_gl_capability(glconfig);
}