GtkWidget* OpenGLModule::registerGLWidget(GtkWidget* widget) { if (++_realisedGLWidgets == 1) { _sharedContext = widget; gtk_widget_ref(_sharedContext); // Create a context gtkutil::GLWidget::makeCurrent(_sharedContext); assertNoErrors(); #ifdef DEBUG_GL_WIDGETS std::cout << "GLWidget: created shared context using "; if (gdk_gl_context_is_direct( gtk_widget_get_gl_context(_sharedContext) ) == TRUE) { std::cout << "DIRECT rendering" << std::endl; } else { std::cout << "INDIRECT rendering" << std::endl; } #endif contextValid = true; sharedContextCreated(); } return _sharedContext; }
void OpenGLModule::registerGLCanvas(wxutil::GLWidget* widget) { std::pair<wxGLWidgets::iterator, bool> result = _wxGLWidgets.insert(widget); if (result.second && _wxGLWidgets.size() == 1) { // First non-duplicated widget registered, take this as context holder _wxSharedContext = new wxGLContext(widget); // Create a context widget->SetCurrent(*_wxSharedContext); assertNoErrors(); _wxContextValid = true; sharedContextCreated(); } }