On Sun, Jan 31, 2010 at 01:24:34PM -0800, Peter Sivak wrote: > Next, all the rendering and drawing commands are done on a > "Gtk::GL::DrawingArea" widget which was created by the GUI thread but I am > using it by the game thread (this could probably be the problem). > > So when for example in the game thread (in the game loop) the > "renderGraphics()" function is called, it wants to do some OpenGL rendering > stuff and when it calls for example the "gtkglextmm" function > "Gtk::GL::DrawingArea::get_gl_context()", the application terminates and > throws me this error: > > (openGLGame:8447): GtkGLExt-CRITICAL **: gtk_widget_get_gl_window: > assertion `GTK_WIDGET_REALIZED (widget)' failed
This basically means that the widget->window GdkWindow (i.e., the X window) for that GtkWidget has not been created yet. The X window is different from a GtkWindow (almost each widget has one). This is created only when the widget gets realized, when the time comes for the widget to be mapped. You can read about it here: http://developer.gnome.org/doc/GGAD/z57.html#SEC-REALIZINGSHOWING Basically, you have to do your setup in the "realize" signal handler for the GtkDrawingArea, or force-realize the widget using gtk_widget_realize(). The GtkDrawingArea has to be realized for get_gl_context() to work. Look at the examples/ directory in the gtkglext source distribution for some examples. > I read something about this on other sites and I there was written that I > should create the OpenGL rendering context (e.g. a "Gdk::GL::Context") on > the same thread which I use it on, or something like that. > > So how can I solve this? Should I construct the "Gtk::GL::DrawingArea" when > I am in the game thread, or should I create a new OpenGL context for the > game thread or what (and how)? It's best as Braden said for you to do all your UI drawing in one thread. If you want to update the UI from multiple threads, it's possible, but not without its quirks. The following are at least _some_ things to watch out for. http://library.gnome.org/devel/gtk-faq/stable/x481.html http://library.gnome.org/devel/gtk-faq/stable/x491.html http://library.gnome.org/devel/gtk-faq/stable/x499.html Mukund _______________________________________________ gtkglext-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkglext-list
