Q:

Gtk, Glade and OpenGL issue

I've got some problems with Gtk+, Glade and GtkGlext.
The code:
#include <gtk-2.0/gtk/gtk.h>
#include <gtkglext-1.0/gtk/gtkgl.h>
#include <GL/gl.h>

GtkBuilder* mBuilder;
GtkWidget* mWindow;
GtkWidget* mAbout;
GtkWidget* mGlArea;
GdkGLConfig *mGlConfig;
GdkGLConfigMode mGlConfigMode;

extern "C" G_MODULE_EXPORT void on_window_destroy(GtkObject *object, gpointer user_data)
{
    gtk_main_quit();
}

extern "C" G_MODULE_EXPORT void on_menuHelpAbout_activate(GtkObject *object, gpointer user_data)
{            
    gtk_widget_show(mAbout);
}

extern "C" G_MODULE_EXPORT void on_aboutdialog1_close(GtkObject *object, gpointer user_data)
{
    gtk_widget_hide(mAbout);
}

extern "C" G_MODULE_EXPORT void configure(GtkWidget *drawarea, GdkEventConfigure *event, gpointer user_data)
{
    printf("%x\n", drawarea);
    GdkGLContext *mGlContext = gtk_widget_get_gl_context(drawarea);
    GdkGLDrawable *mGlDrawable = gtk_widget_get_gl_drawable(drawarea);

    gdk_gl_drawable_gl_begin(mGlDrawable, mGlContext);

    glLoadIdentity();   
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    gdk_gl_drawable_gl_end(mGlDrawable);
}

extern "C" G_MODULE_EXPORT void expose(GtkWidget *drawarea, GdkEventExpose *event, gpointer user_data)
{
    GdkGLContext *mGlContext = gtk_widget_get_gl_context(drawarea);
    GdkGLDrawable *mGlDrawable = gtk_widget_get_gl_drawable(drawarea);

    gdk_gl_drawable_gl_begin(mGlDrawable, mGlContext);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    glLoadIdentity();

    gdk_gl_drawable_swap_buffers(mGlDrawable);

    gdk_gl_drawable_gl_end(mGlDrawable);
}

int main(int argc, char *argv[])
{
    gtk_init(&argc, &argv);
    gtk_gl_init(&argc, &argv);

    mBuilder = gtk_builder_new();
    gtk_builder_add_from_file(mBuilder, "editor.xml", NULL);
    mWindow = GTK_WIDGET(gtk_builder_get_object(mBuilder, "window"));
    mAbout = GTK_WIDGET(gtk_builder_get_object(mBuilder, "aboutdialog1"));
    mGlArea = GTK_WIDGET(gtk_builder_get_object(mBuilder, "drawingarea1"));
    gtk_widget_set_events(mGlArea, GDK_EXPOSURE_MASK);
    gtk_builder_connect_signals(mBuilder, NULL);

    g_object_unref(G_OBJECT(mBuilder));

    gtk_widget_show(mWindow);

    if(gtk_widget_get_realized(mGlArea))
    {
        gtk_widget_unrealize(mGlArea);
    }

    mGlConfigMode = (GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_STENCIL);

    mGlConfig = gdk_gl_config_new_by_mode(mGlConfigMode);
    if(!mGlConfig)
    {
        printf("Error: Can't get OpenGL configuration\n");
    }

    if(!gtk_widget_set_gl_capability(mGlArea, mGlConfig, NULL, TRUE, GDK_GL_RGBA_TYPE))
    {
        printf("Error: Can't set OpenGL capability to drawable area\n");
    }

    g_signal_connect(mGlArea, "configure-event", G_CALLBACK(configure), NULL);
    g_signal_connect(mGlArea, "expose-event", G_CALLBACK(expose), NULL);

    gtk_widget_show_all(mWindow);

    gtk_main();

    return 0;
}

I actually don't know why I get segmentation fault at line 30, as address seems valid and initialization of OpenGL is successful. Could anyone point me in right direction?

A:

Yup and problem solved... issue is not in the code, but during compiling and linking phase. My libgtkglext-x11-1.0 was somehow corrupt (gdb screamed that XVisualIDFromVisual did SIGSEGV), so I thought it might be corrupt and recompiled it.

