Hi there, Michael !
Well, hoping to get some help, I converted everything to pure C.
Here are the 5 steps to bug (A.K.A. the source code)
#include <gtk/gtk.h>
// ===================================================
// A do-minimum GtkGlArea realize_callback
// ===================================================
gboolean realize_cb(GtkGLArea *area, gpointer udata)
{
gtk_gl_area_make_current(area);
if(gtk_gl_area_get_error(area) != NULL)
{
printf(" failed to initialiize buffers...\n");
return FALSE;
}
return TRUE;
}
// ===================================================
// A don't touch anything GtkGlArea render_callback
// ===================================================
gboolean render_cb(GtkGLArea *area, GdkGLContext *context, gpointer udata)
{
return TRUE;
}
// ===================================================
// main
// ===================================================
int main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
// 1. The main widget
GtkWidget *pMainWidget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(pMainWidget), 400, 400);
// 2. The gl_area widget
GtkWidget *pGlWidget = gtk_gl_area_new();
gtk_gl_area_set_has_depth_buffer(GTK_GL_AREA(pGlWidget), TRUE);
// 3. the header_bar wishing to become title_bar
GtkWidget *pHeaderBar = gtk_header_bar_new();
gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(pHeaderBar), TRUE);
gtk_window_set_titlebar(GTK_WINDOW(pMainWidget), pHeaderBar);
gtk_window_set_title(GTK_WINDOW(pMainWidget), "simple bug");
// 4. add glarea_widget to main
gtk_container_add(GTK_CONTAINER(pMainWidget), pGlWidget);
// 5. and finally, connect the signals
g_signal_connect(pMainWidget, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(pGlWidget, "realize", G_CALLBACK(realize_cb), NULL);
g_signal_connect(pGlWidget, "render", G_CALLBACK(render_cb), NULL);
gtk_widget_show_all(pMainWidget);
// Ok, lets bug !!!!
gtk_main();
return 0;
}
If you have a linux machine and want help, please :
- copy the source code to a empty hello.c text file and compile with
gcc `pkg-config --cflags gtk+-3.0` hello.c -o hello `pkg-config --libs gtk+-3.0`
./hello
I guess it will show a bugged window. If not (and of course, if yes) please let me know.
What happened here ?
-
commenting only the line 43 (gtk_window_set_titlebar(…)) causes the program to show a black glarea and not the header_bar (as expected).
-
commenting only the line 47 (gtk_container_add(…)) causes the program to show the header_bar and not the glarea (also, as expected).
-
uncommenting both lines, causes the program to show some garbage that remotely resembles a window (not as expected).
Please someone shed some light on this problem. Or, at least, check if this behavior is observed on a machine other than mine.
Regards,
Chimp.