GtkWidget * yui_gl_new(void) { GtkWidget * drawingArea; #ifdef HAVE_LIBGTKGLEXT int attribs[] = { GDK_GL_RGBA, GDK_GL_RED_SIZE, 1, GDK_GL_GREEN_SIZE, 1, GDK_GL_BLUE_SIZE, 1, GDK_GL_DOUBLEBUFFER, GDK_GL_DEPTH_SIZE ,1, GDK_GL_STENCIL_SIZE ,8, GDK_GL_ATTRIB_LIST_NONE }; #endif drawingArea = GTK_WIDGET(g_object_new(yui_gl_get_type(), NULL)); YUI_GL(drawingArea)->is_init = 0; #ifdef HAVE_LIBGTKGLEXT gtk_widget_set_gl_capability(drawingArea, gdk_gl_config_new(attribs), NULL, TRUE, GDK_GL_RGBA_TYPE); #endif g_signal_connect (GTK_OBJECT(drawingArea),"configure_event", GTK_SIGNAL_FUNC(yui_gl_resize),0); gtk_widget_set_events(drawingArea, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); g_signal_connect(GTK_OBJECT(drawingArea), "motion-notify-event", GTK_SIGNAL_FUNC(yui_gl_hide_cursor),0); g_signal_connect(GTK_OBJECT(drawingArea), "button-press-event", GTK_SIGNAL_FUNC(yui_gl_button_press),0); g_signal_connect(GTK_OBJECT(drawingArea), "button-release-event", GTK_SIGNAL_FUNC(yui_gl_button_release),0); return drawingArea; }
int main(int argc, char **argv) { gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *drawing = gtk_drawing_area_new(); GdkGLConfig *glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)( GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_ALPHA)); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL); g_signal_connect(drawing, "expose-event", G_CALLBACK(on_expose), NULL); g_signal_connect(drawing, "configure-event", G_CALLBACK(on_configure), NULL); gtk_widget_set_gl_capability(drawing, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_container_add(GTK_CONTAINER(window), drawing); gtk_widget_show_all(window); /* OpenGL setup */ GdkGLContext *glcontext = gtk_widget_get_gl_context(GTK_WIDGET(drawing)); GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable(GTK_WIDGET(drawing)); gdk_gl_drawable_gl_begin(gldrawable, glcontext); /* Go */ gtk_main(); gdk_gl_drawable_gl_end(gldrawable); }
void realizeOpenGL(struct OpenGL* ogl, long long gtkWindow_) { GtkWidget* window = GTK_WIDGET((void*) gtkWindow_); GdkGLConfig * config = gdk_gl_config_new_by_mode_for_screen( gdk_screen_get_default(), GDK_GL_MODE_RGB | GDK_GL_MODE_SINGLE/*| GDK_GL_MODE_DOUBLE*/); if (config == NULL) return; //printf("ogl=%p\n", ogl); ogl->config = config; gtk_widget_unrealize(window); if (!gtk_widget_set_gl_capability(window, ogl->config, NULL, FALSE, GDK_GL_RGBA_TYPE)) { fprintf(stderr, "Cannot enable GDKGL on window"); return; } gtk_widget_realize(window); GdkGLDrawable* drawable = gtk_widget_get_gl_drawable(GTK_WIDGET(window)); ogl->drawable = drawable; ogl->widget = GTK_WIDGET(window); ogl->context = gtk_widget_get_gl_context(ogl->widget); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_SHORT, 0, ogl->vertices); //gdk_gl_drawable_gl_begin(ogl->drawable, ogl->context); }
GtkWidget * StatGraph(GraphData * pgd) { float f1, f2; GtkWidget *pw; /* Drawing area for OpenGL */ pw = gtk_drawing_area_new(); /* Set OpenGL-capability to the widget - no list sharing */ if ((pw == NULL) || !gtk_widget_set_gl_capability(pw, getGlConfig(), NULL, TRUE, GDK_GL_RGBA_TYPE)) { g_print("Can't create opengl capable widget\n"); return NULL; } f1 = pgd->data[pgd->numGames][0][0] + pgd->data[pgd->numGames][0][1]; f2 = pgd->data[pgd->numGames][1][0] + pgd->data[pgd->numGames][1][1]; pgd->maxY = (f1 > f2) ? f1 : f2; if (pgd->maxY < .5f) pgd->maxY = .5f; gtk_widget_set_events(pw, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(pw), "button_press_event", G_CALLBACK(graph_button_press_event), pgd); g_signal_connect(G_OBJECT(pw), "realize", G_CALLBACK(realize), pgd); g_signal_connect(G_OBJECT(pw), "configure_event", G_CALLBACK(configure_event), pgd); g_signal_connect(G_OBJECT(pw), "expose_event", G_CALLBACK(expose_event), pgd); g_signal_connect(G_OBJECT(pw), "destroy", G_CALLBACK(destroy_event), NULL); return pw; }
int window_system_initialise(int argc, char ***argv) { gtk_init(&argc, argv); gtk_gl_init(&argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW (window), DEFAULT_WIN_WIDTH, DEFAULT_WIN_HEIGHT); drawing_area = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), drawing_area); g_signal_connect_swapped(window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_set_events(drawing_area, GDK_EXPOSURE_MASK); gl_config = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); if (!gl_config) { printf("Messed up the config :(\n"); exit(1); } if (!gtk_widget_set_gl_capability(drawing_area, gl_config, NULL, TRUE, GDK_GL_RGBA_TYPE)) { printf("Couldn't get capabilities we needed :(\n"); exit(1); } return 0; }
native_handle _chisel_native_openglview_create( ) { static int glsetup = 0; if ( !glsetup ) { gtk_gl_init_check( NULL, NULL ); glsetup = 1; } GtkWidget *widget = gtk_drawing_area_new( ); gtk_widget_set_size_request (widget, 120, 120); _chisel_gtk_setup_events( widget ); //g_signal_connect( G_OBJECT(widget), "size_allocate", G_CALLBACK(_chisel_native_openglview_resize_event), NULL ); //g_signal_connect_after( G_OBJECT(widget), "configure-event", G_CALLBACK(_chisel_native_openglview_configure_event), NULL ); // gtk_widget_set_events( widget, GDK_EXPOSURE_MASK ); GdkGLConfigMode glcmode = (GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); GdkGLConfig *glconfig = gdk_gl_config_new_by_mode( glcmode ); assert( glconfig != NULL ); assert( gtk_widget_set_gl_capability( widget, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE ) ); g_signal_connect( G_OBJECT(widget), "expose-event", G_CALLBACK(_chisel_native_openglview_expose_event), NULL ); return widget; }
int main (int argc, char* argv[]) { GtkWidget* window; GtkWidget* drawarea; GdkGLConfig* glconfig; gtk_init (&argc, &argv); gdk_gl_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); drawarea = gtk_drawing_area_new (); gtk_widget_set_size_request (drawarea, 400, 300); gtk_container_add (GTK_CONTAINER (window), drawarea); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_set_events (drawarea, GDK_EXPOSURE_MASK); glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); gtk_widget_set_gl_capability (drawarea, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_signal_connect (GTK_OBJECT (drawarea), "expose-event", G_CALLBACK (display), NULL); gtk_signal_connect (GTK_OBJECT (drawarea), "configure-event", G_CALLBACK (reshape), NULL); g_idle_add (idle, drawarea); gtk_widget_show_all (window); gtk_main (); return 0; }
OSRWindow::OSRWindow(OSRBrowserProvider* browser_provider, bool transparent, ClientWindowHandle parentView) : renderer_(transparent), browser_provider_(browser_provider), gl_enabled_(false), painting_popup_(false), render_task_pending_(false) { glarea_ = gtk_drawing_area_new(); DCHECK(glarea_); GdkGLConfig* glconfig = gdk_gl_config_new_by_mode( static_cast<GdkGLConfigMode>(GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); DCHECK(glconfig); gtk_widget_set_gl_capability(glarea_, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_widget_set_can_focus(glarea_, TRUE); g_signal_connect(G_OBJECT(glarea_), "size_allocate", G_CALLBACK(glarea_size_allocation), this); gtk_widget_set_events(glarea_, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_SCROLL_MASK | GDK_FOCUS_CHANGE_MASK); g_signal_connect(G_OBJECT(glarea_), "button_press_event", G_CALLBACK(glarea_click_event), this); g_signal_connect(G_OBJECT(glarea_), "button_release_event", G_CALLBACK(glarea_click_event), this); g_signal_connect(G_OBJECT(glarea_), "key_press_event", G_CALLBACK(glarea_key_event), this); g_signal_connect(G_OBJECT(glarea_), "key_release_event", G_CALLBACK(glarea_key_event), this); g_signal_connect(G_OBJECT(glarea_), "enter_notify_event", G_CALLBACK(glarea_move_event), this); g_signal_connect(G_OBJECT(glarea_), "leave_notify_event", G_CALLBACK(glarea_move_event), this); g_signal_connect(G_OBJECT(glarea_), "motion_notify_event", G_CALLBACK(glarea_move_event), this); g_signal_connect(G_OBJECT(glarea_), "scroll_event", G_CALLBACK(glarea_scroll_event), this); g_signal_connect(G_OBJECT(glarea_), "focus_in_event", G_CALLBACK(glarea_focus_event), this); g_signal_connect(G_OBJECT(glarea_), "focus_out_event", G_CALLBACK(glarea_focus_event), this); gtk_container_add(GTK_CONTAINER(parentView), glarea_); }
int main (int argc, char *argv[]) { unicap_handle_t handle; unicap_format_t format; /* Initialize */ gtk_init (&argc, &argv); g_thread_init(NULL); gdk_threads_init (); gtk_gl_init (&argc, &argv); init_extensions (); init_gl_resources (); handle = open_device(); set_format( handle ); unicap_get_format( handle, &format ); if( ( format.size.width != 640 ) || ( format.size.height != 480 ) ) { g_warning( "The default .cg file assumes a video format of 640x480 pixels. \nYou need to change the yuv.cg file to match your size.\n" ); } prepare_yuv_buffer(&yuvbuffer, &format); unicap_register_callback( handle, UNICAP_EVENT_NEW_FRAME, (unicap_callback_t)new_frame_cb, NULL ); unicap_start_capture( handle ); /* Gtk window & container */ GtkWindow *window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_TOPLEVEL)); glarea = gtk_drawing_area_new (); gtk_widget_set_size_request (GTK_WIDGET (glarea), WINDOW_WIDTH, WINDOW_HEIGHT); g_signal_connect (glarea, "expose-event", G_CALLBACK (on_expose), NULL); g_signal_connect (glarea, "configure-event", G_CALLBACK (on_configure), NULL); g_signal_connect (glarea, "map-event", G_CALLBACK (on_mapped), NULL); g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); GdkGLConfig *gl_config; gl_config = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE); if (gl_config == NULL) g_critical ("Failed to setup a double-buffered RGB visual"); if (! gtk_widget_set_gl_capability (GTK_WIDGET (glarea), gl_config, NULL, TRUE, GDK_GL_RGBA_TYPE)) g_critical ("Failed to add gl capability"); gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (glarea)); gtk_widget_show_all (GTK_WIDGET (window)); /* Main loop */ gtk_main (); return 0; }
void GtkGlExtGlue::prepDrawingArea(GtkWidget *drawing_area) { // GNASH_REPORT_FUNCTION; _drawing_area = drawing_area; gtk_widget_set_gl_capability(_drawing_area, _glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); }
void GLBase::init(GdkGLConfig *Config, int PixFormat) { gtk_widget_set_gl_capability(widget->GetWidget(), Config, NULL, true, PixFormat); gtk_widget_set_app_paintable(widget->GetWidget(), true); Conf = Config; ctx = NULL; drw = NULL; TimeoutID = 0; }
GtkWidget* WINAPI gtk_glwidget_new( gboolean zbuffer, GtkWidget* share ){ GtkWidget* drawing_area = gtk_drawing_area_new(); GdkGLConfig* glconfig = ( zbuffer ) ? glconfig_new_with_depth() : glconfig_new(); GdkGLContext* shared_context = ( share ) ? gtk_widget_get_gl_context( share ) : NULL; gtk_widget_set_gl_capability( drawing_area, glconfig, shared_context, TRUE, GDK_GL_RGBA_TYPE ); return drawing_area; }
void CGLDrawingArea::MakeDrawingAreaAnOpenGLContext() /***************************************/ { GtkWidget* widget = reinterpret_cast<GtkWidget*>(gobj()); gtk_widget_set_gl_capability(widget, GLConfig(), NULL, TRUE, GDK_GL_RGBA_TYPE); }
void draw_setup(GtkDrawingArea *draw, struct program *p) { GObject *obj = G_OBJECT(draw); gtk_widget_set_gl_capability(GTK_WIDGET(draw), p->draw.config, NULL, TRUE, GDK_GL_RGBA_TYPE); g_signal_connect_after(obj, "realize", G_CALLBACK(realize), p); g_signal_connect(obj, "configure-event", G_CALLBACK(configure), p); g_signal_connect(obj, "expose-event", G_CALLBACK(expose), p); }
//view void mShowToolBoxSlot(GtkWidget * widget, gpointer user_data) { if (!gtk_widget_set_gl_capability (glade_xml_get_widget(xml, "glfixed"), configure_gl(), gtk_widget_get_gl_context(view->drawing_area), 0, 0)) printf("glwidget creation failed \n"); }
bool OSGGTKDrawingArea::createWidget(int width, int height) { _glconfig = gdk_gl_config_new_by_mode(static_cast<GdkGLConfigMode>( GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE )); if(not _glconfig) { osg::notify(osg::FATAL) << "Fail!" << std::endl; return false; } gtk_widget_set_size_request(_widget, width, height); gtk_widget_set_gl_capability( _widget, _glconfig, 0, true, GDK_GL_RGBA_TYPE ); gtk_widget_add_events( _widget, GDK_BUTTON1_MOTION_MASK | GDK_BUTTON2_MOTION_MASK | GDK_BUTTON3_MOTION_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_VISIBILITY_NOTIFY_MASK ); // We do this so that we don't have to suck up ALL the input to the // window, but instead just when the drawing area is focused. g_object_set(_widget, "can-focus", true, NULL); _connect("realize", G_CALLBACK(&OSGGTKDrawingArea::_srealize)); _connect("unrealize", G_CALLBACK(&OSGGTKDrawingArea::_sunrealize)); _connect("expose_event", G_CALLBACK(&OSGGTKDrawingArea::_sexpose_event)); _connect("configure_event", G_CALLBACK(&OSGGTKDrawingArea::_sconfigure_event)); _connect("motion_notify_event", G_CALLBACK(&OSGGTKDrawingArea::_smotion_notify_event)); _connect("button_press_event", G_CALLBACK(&OSGGTKDrawingArea::_sbutton_press_event)); _connect("button_release_event", G_CALLBACK(&OSGGTKDrawingArea::_sbutton_press_event)); _connect("key_press_event", G_CALLBACK(&OSGGTKDrawingArea::_skey_press_event)); _gw = setUpViewerAsEmbeddedInWindow(0, 0, width, height); return true; }
int main (int argc, char **argv) { RunAllTests(); GtkWidget *window; GtkWidget *da; GdkGLConfig *glconfig; gtk_init (&argc, &argv); gtk_gl_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 800, 600); da = gtk_drawing_area_new (); gtk_container_add (GTK_CONTAINER (window), da); g_signal_connect_swapped (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_set_events (da, GDK_EXPOSURE_MASK); gtk_widget_show (window); /* prepare GL */ glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode) (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); if (!glconfig) { g_assert_not_reached (); } if (!gtk_widget_set_gl_capability (da, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) { g_assert_not_reached (); } g_signal_connect (da, "configure-event", G_CALLBACK (configure), NULL); g_signal_connect (da, "expose-event", G_CALLBACK (expose), NULL); gtk_widget_show_all (window); g_timeout_add (1000 / 30, rotate, da); t3dInit(); gtk_main (); }
void Interface_iniciar() { GtkWidget *window; GdkGLConfig *glconfig; gtk_init(NULL, NULL); gtk_gl_init(NULL, NULL); GtkBuilder *builderPrincipal=Interface_carregarXML(INTERFACE_PRINCIPAL); window = GTK_WIDGET(gtk_builder_get_object (builderPrincipal, "window")); drawOpengl=GTK_WIDGET(gtk_builder_get_object(builderPrincipal, "drawOpengl")); frameProgresso=GTK_WIDGET(gtk_builder_get_object(builderPrincipal, "frameProgresso")); progress=GTK_PROGRESS_BAR(gtk_builder_get_object(builderPrincipal, "progressbar")); labelPosicaoXY=GTK_LABEL(gtk_builder_get_object(builderPrincipal, "labelPosicaoXY")); ajustScrollHorizGL=GTK_ADJUSTMENT(gtk_builder_get_object(builderPrincipal, "ajustScrollHorizGL")); ajustScrollVertGL=GTK_ADJUSTMENT(gtk_builder_get_object(builderPrincipal, "ajustScrollVertGL")); adjustAlpha=GTK_ADJUSTMENT(gtk_builder_get_object(builderPrincipal, "adjustAlpha")); tbAddEntidade=GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builderPrincipal, "tbAddEntidade")); tbAddImagem=GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builderPrincipal, "tbAddImagem")); tbAddTexto=GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builderPrincipal, "tbAddTexto")); tbAmpliar=GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builderPrincipal, "tbAmpliar")); tbReduzir=GTK_TOGGLE_TOOL_BUTTON(gtk_builder_get_object(builderPrincipal, "tbReduzir")); frameFerramentas=GTK_WIDGET(gtk_builder_get_object(builderPrincipal, "frameFerramentas")); /*gtk_adjustment_set_value(GTK_ADJUSTMENT(gtk_builder_get_object(builderPrincipal, "ajustScrollHorizGL")),500); gtk_adjustment_set_value(GTK_ADJUSTMENT(gtk_builder_get_object(builderPrincipal, "ajustScrollVertGL")),500);*/ //Configura widget para opengl glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); if (!glconfig) { g_print ("*** Cannot find the double-buffered visual.\n"); g_print ("*** Trying single-buffered visual.\n"); /* Try single-buffered visual */ glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH); if (!glconfig) { g_print ("*** No appropriate OpenGL-capable visual found.\n"); g_assert_not_reached(); } } if (!gtk_widget_set_gl_capability(drawOpengl, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) g_assert_not_reached(); gtk_builder_connect_signals(builderPrincipal, NULL); gtk_widget_show(window); g_object_unref(G_OBJECT(builderPrincipal)); }
RenderArea::RenderArea(RenderAreaPtr theContext) : AbstractRenderWindow(jslib::JSApp::ShellErrorReporter), _myContextRefCount(0), _isFirstFrame(true) { GdkGLConfig * myGLConfig = gdk_gl_config_new_by_mode( GdkGLConfigMode(GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_ALPHA)); if (myGLConfig == 0) { throw asl::Exception("can't init GL",PLUS_FILE_LINE); } // If another render area is supplied as constructor paramter, this render area is uses as // source for a shared y60-gl-context and gdk-gl-context. GdkGLContext * myGdkGLContext = 0; if (theContext) { myGdkGLContext = theContext->getGdkGlContext(); if (!myGdkGLContext) { throw asl::Exception("RenderArea: Failed to get gdk GL context from shared render area.", PLUS_FILE_LINE); } setGLContext(theContext->getGLContext()); } else { setGLContext(GLContextPtr(new GLContext())); } /* Set OpenGL-capability to the widget. */ DB(cerr << "RenderArea::RenderArea() sharing with " << myGdkGLContext << endl); if (!gtk_widget_set_gl_capability (GTK_WIDGET(gobj()), myGLConfig, myGdkGLContext, true, GDK_GL_RGBA_TYPE)) { throw asl::Exception("RenderArea: could not create GL context!", PLUS_FILE_LINE); } // enable mouse events Gdk::EventMask flags = get_events(); flags |= Gdk::BUTTON_PRESS_MASK; flags |= Gdk::POINTER_MOTION_MASK; flags |= Gdk::BUTTON_RELEASE_MASK; flags |= Gdk::SCROLL_MASK; flags |= Gdk::ENTER_NOTIFY_MASK; flags |= Gdk::LEAVE_NOTIFY_MASK; set_events(flags); y60::EventDispatcher::get().addSource(&_myEventAdapter); y60::EventDispatcher::get().addSink(this); // TODO: createRenderer(theOtherRenderer); ShaderLibrary::setGLisReadyFlag(true); }
Render::Render (View *view, Glib::RefPtr<Gtk::TreeSelection> selection) : m_arcBall(new ArcBall()), m_view (view), m_selection(selection) { set_events (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK | Gdk::BUTTON3_MOTION_MASK); GdkGLConfig *glconfig; // glconfig is leaked at program exit glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_ALPHA | GDK_GL_MODE_STENCIL | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE)); if (!glconfig) // try single buffered glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode) (GDK_GL_MODE_RGBA | GDK_GL_MODE_ALPHA | GDK_GL_MODE_STENCIL | GDK_GL_MODE_DEPTH)); if (!gtk_widget_set_gl_capability (get_widget(), glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) g_error (_("failed to init gl area\n")); memset (&m_transform.M, 0, sizeof (m_transform.M)); Matrix3fT identity; Matrix3fSetIdentity(&identity); // set initial rotation 30 degrees around Y axis identity.s.M11 = identity.s.M22 = 0.5253; // cos -45 identity.s.M12 = 0.851; // -sin -45 identity.s.M21 = -0.851; // sin -45 Matrix4fSetRotationScaleFromMatrix3f(&m_transform, &identity); m_transform.s.SW = 1.0; m_zoom = 120.0; for (uint i = 0; i < N_LIGHTS; i++) m_lights[i] = NULL; m_selection->signal_changed().connect (sigc::mem_fun(*this, &Render::selection_changed)); }
gboolean glwidget_enable_gl( GtkWidget* widget, GtkWidget* widget2, gpointer data ){ if ( widget2 == 0 && !gtk_widget_is_gl_capable( widget ) ) { GdkGLConfig* glconfig = ( g_object_get_data( G_OBJECT( widget ), "zbuffer" ) ) ? glconfig_new_with_depth() : glconfig_new(); ASSERT_MESSAGE( glconfig != 0, "failed to create OpenGL config" ); gtk_widget_set_gl_capability( widget, glconfig, g_shared != 0 ? gtk_widget_get_gl_context( g_shared ) : 0, TRUE, GDK_GL_RGBA_TYPE ); gtk_widget_realize( widget ); if ( g_shared == 0 ) { g_shared = widget; } // free glconfig? } return FALSE; }
WaveformView* construct () { WaveformView* self = (WaveformView*) g_object_new (TYPE_WAVEFORM_VIEW, NULL); gtk_widget_add_events ((GtkWidget*) self, (gint) ((GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) | GDK_POINTER_MOTION_MASK)); gtk_widget_set_size_request ((GtkWidget*) self, 200, 100); //GdkGLConfig* glconfig = gdk_gl_config_new_by_mode (GDK_GL_MODE_RGB | GDK_GL_MODE_DOUBLE); if(!gtk_widget_set_gl_capability((GtkWidget*)self, glconfig, gl_context, DIRECT, GDK_GL_RGBA_TYPE)){ gwarn("failed to set gl capability"); } WaveformViewPrivate* priv = self->priv; priv->gl_init_done = false; return self; }
static int lglext_widget_set_gl_capability(lua_State* L) { luaL_checktype(L, 1, LUA_TUSERDATA); luaL_checktype(L, 2, LUA_TUSERDATA); luaL_checktype(L, 3, LUA_TBOOLEAN); luaL_checktype(L, 4, LUA_TNUMBER); Object* obj1 = lua_touserdata(L, 1); Object* obj2 = lua_touserdata(L, 2); gboolean res = gtk_widget_set_gl_capability(GTK_WIDGET(obj1->pointer), GDK_GL_CONFIG(obj2->pointer), NULL, lua_toboolean(L, 3), lua_tointeger(L, 4)); lua_pushboolean(L, res); return 1; }
int main (int argc, char *argv[]) { set_log_handlers(); wf_debug = 1; gtk_init(&argc, &argv); GdkGLConfig* glconfig; if(!(glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE))){ gerr ("Cannot initialise gtkglext."); return EXIT_FAILURE; } GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); canvas = gtk_drawing_area_new(); gtk_widget_set_can_focus (canvas, true); gtk_widget_set_size_request (canvas, GL_WIDTH + 2 * HBORDER, 128); gtk_widget_set_gl_capability (canvas, glconfig, NULL, 1, GDK_GL_RGBA_TYPE); gtk_widget_add_events (canvas, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); gtk_container_add((GtkContainer*)window, (GtkWidget*)canvas); agl = agl_get_instance(); scene = (AGlRootActor*)agl_actor__new_root(canvas); wfc = wf_canvas_new((AGlRootActor*)scene); char* filename = find_wav(WAV); w1 = waveform_load_new(filename); g_free(filename); g_signal_connect((gpointer)canvas, "realize", G_CALLBACK(on_canvas_realise), NULL); g_signal_connect((gpointer)canvas, "size-allocate", G_CALLBACK(on_allocate), NULL); g_signal_connect((gpointer)canvas, "expose-event", G_CALLBACK(agl_actor__on_expose), scene); gtk_widget_show_all(window); add_key_handlers((GtkWindow*)window, NULL, (Key*)&keys); gboolean window_on_delete(GtkWidget* widget, GdkEvent* event, gpointer user_data){ gtk_main_quit(); return false; }
static void grits_tester_init(GritsTester *tester) { g_debug("GritsTester: init"); tester->objects = NULL; /* Set OpenGL before "realize" */ GdkGLConfig *glconfig = gdk_gl_config_new_by_mode( GDK_GL_MODE_RGBA | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_ALPHA); if (!glconfig) g_error("Failed to create glconfig"); if (!gtk_widget_set_gl_capability(GTK_WIDGET(tester), glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) g_error("GL lacks required capabilities"); g_object_unref(glconfig); /* Finish OpenGL init after it's realized */ g_signal_connect(tester, "realize", G_CALLBACK(on_realize), NULL); }
static void cb_init_ext(GtkWidget *widget) { GdkGLConfig *config; // la config qui va aller avec static const gint attrList[] = { // les paramètres de la config GDK_GL_DOUBLEBUFFER, GDK_GL_RGBA, GDK_GL_RED_SIZE, 1, GDK_GL_GREEN_SIZE, 1, GDK_GL_BLUE_SIZE, 1, GDK_GL_ALPHA_SIZE, 1, GDK_GL_DEPTH_SIZE, 1, GDK_GL_ATTRIB_LIST_NONE }; config = gdk_gl_config_new(attrList); /* ajout du support Opengl */ gtk_widget_set_gl_capability(widget, config, NULL, TRUE, GDK_GL_RGBA_TYPE); }
int darxen_splash_run() { GMainLoop *loop; int i; if (mfrmSplash) g_error("Splash screen has been shown already"); for (i = 0; i < PROGRESS_COUNT; i++) intProgressTimeTotal += objProgressItems[i].intTime; glSettings = (SettingsGL*)malloc(sizeof(SettingsGL)); mfrmSplash = gtk_window_new(GTK_WINDOW_POPUP); gtk_window_set_decorated(GTK_WINDOW(mfrmSplash), FALSE); gtk_window_set_title(GTK_WINDOW(mfrmSplash), "loading DARXEN..."); gtk_window_set_position(GTK_WINDOW(mfrmSplash), GTK_WIN_POS_CENTER); darxen_splash_gl_init(); darea = gtk_drawing_area_new(); gtk_widget_set_gl_capability(darea, glSettings->glConfig, NULL, TRUE, GDK_GL_RGBA_TYPE); g_signal_connect(darea, "realize", (GCallback)darxen_splash_darea_realize, NULL); g_signal_connect(darea, "configure_event", (GCallback)darxen_splash_darea_configure, NULL); g_signal_connect(darea, "expose_event", (GCallback)darxen_splash_darea_expose, NULL); gtk_widget_set_size_request(darea, 300, 200); gtk_container_add(GTK_CONTAINER(mfrmSplash), darea); gtk_widget_show_all(mfrmSplash); loop = g_main_loop_new(NULL, FALSE); g_timeout_add_full(G_PRIORITY_LOW, 100, darxen_splash_load, loop, NULL); g_main_loop_run(loop); g_main_loop_unref(loop); gtk_widget_hide(mfrmSplash); return 0; }
/// Returns a "global" (to the document) gdkgl context that can be used to share display lists GdkGLContext* gdkgl_share_list() { if(!m_gdkgl_share_list) { GdkGLConfig* const config = gdk_gl_config_new_by_mode( static_cast<GdkGLConfigMode>(GDK_GL_MODE_RGBA | GDK_GL_MODE_DOUBLE | GDK_GL_MODE_DEPTH)); return_val_if_fail(config, 0); Gtk::Window* const window = new Gtk::Window(); gtk_widget_set_gl_capability(GTK_WIDGET(window->gobj()), config, 0, true, GDK_GL_RGBA_TYPE); window->show(); window->hide(); GdkGLContext* const context = gtk_widget_get_gl_context(GTK_WIDGET(window->gobj())); return_val_if_fail(context, 0); m_gdkgl_share_list = context; } return m_gdkgl_share_list; }
static GtkWidget * CreateGLPreviewWidget(Material * pMat) { /* Rename this (and the one above to CreateGLBoardWidget) */ GtkWidget *p3dWidget = gtk_drawing_area_new(); /* Set OpenGL-capability to the widget - no list sharing */ if (!gtk_widget_set_gl_capability(p3dWidget, getGlConfig(), NULL, TRUE, GDK_GL_RGBA_TYPE)) { outputerrf("Can't create opengl capable widget\n"); return NULL; } if (p3dWidget == NULL) { outputerrf("Can't create opengl drawing widget\n"); return NULL; } g_signal_connect(G_OBJECT(p3dWidget), "realize", G_CALLBACK(realize_preview3d), NULL); g_signal_connect(G_OBJECT(p3dWidget), "expose_event", G_CALLBACK(expose_event_preview3d), pMat); return p3dWidget; }
gboolean GLWidget::onHierarchyChanged(GtkWidget* widget, GtkWidget* previous_toplevel, GLWidget* self) { if (previous_toplevel == NULL && !gtk_widget_is_gl_capable(widget)) { // Create a new GL config structure GdkGLConfig* glconfig = (self->_zBuffer) ? createGLConfigWithDepth() : createGLConfig(); ASSERT_MESSAGE(glconfig != NULL, "failed to create OpenGL config"); gtk_widget_set_gl_capability(widget, glconfig, g_shared != NULL ? gtk_widget_get_gl_context(g_shared) : NULL, TRUE, GDK_GL_RGBA_TYPE); gtk_widget_realize(widget); // Shared not set yet? if (g_shared == 0) { g_shared = widget; } } return FALSE; }