public Gdk.Colormap GetColormap(Gdk.Screen screen, ) { DrawableFormat template = new DrawableFormat(); template.Color = new ColorFormat(); FormatMask mask = FormatMask.None; int num = screen.Number; IntPtr dformat = GlitzAPI.glitz_glx_find_window_format(GdkUtils.GetXDisplay(screen.Display), num, mask, ref template, 0); visual_info = GlitzAPI.glitz_glx_get_visual_info_from_format(dpy, scr, dformat); Gdk.Visual visual = new Gdk.Visual(gdkx_visual_get(XVisualIDFromVisual(vinfo))); new Gdk.Colormap(visual, true); * / }
public static Cairo.Surface SetUp(Gdk.Drawable gdk_drawable) { IntPtr x_drawable = gdk_drawable.Handle; IntPtr dpy = gdk_x11_drawable_get_xdisplay(x_drawable); int scr = 0; IntPtr visual = gdk_drawable_get_visual(x_drawable); IntPtr Xvisual = gdk_x11_visual_get_xvisual(visual); uint XvisualID = XVisualIDFromVisual(Xvisual); Console.WriteLine("XvisID: " + XvisualID); IntPtr fmt = GlitzAPI.glitz_glx_find_drawable_format_for_visual(dpy, scr, XvisualID); Console.WriteLine("fmt: " + fmt); //IntPtr Xdrawable = gdk_x11_drawable_get_xid (x_drawable); uint win = gdk_x11_drawable_get_xid(x_drawable); uint w = 100, h = 100; IntPtr glitz_drawable = GlitzAPI.glitz_glx_create_drawable_for_window(dpy, scr, fmt, win, w, h); //NDesk.Glitz.Drawable ggd = new NDesk.Glitz.Drawable (glitz_drawable); ggd = new NDesk.Glitz.Drawable(glitz_drawable); IntPtr glitz_format = ggd.FindStandardFormat(FormatName.ARGB32); ggs = new NDesk.Glitz.Surface(ggd, glitz_format, 100, 100, 0, IntPtr.Zero); Console.WriteLine(ggd.Features); ggs.Attach(ggd, doublebuffer ? DrawableBuffer.BackColor : DrawableBuffer.FrontColor); //GlitzAPI.glitz_drawable_destroy (glitz_drawable); GlitzSurface gs = new GlitzSurface(ggs.Handle); //GlitzSurface gs = null; return(gs); }
public static Cairo.Surface Realize(Widget widget) { IntPtr dpy = gdk_x11_get_default_xdisplay(); int scr = gdk_x11_get_default_screen(); DrawableFormat template = new DrawableFormat(); template.Color = new ColorFormat(); FormatMask mask = FormatMask.None; //template.Doublebuffer = doublebuffer; //mask |= FormatMask.Doublebuffer; IntPtr dformat = GlitzAPI.glitz_glx_find_window_format(dpy, scr, mask, ref template, 0); if (dformat == IntPtr.Zero) { throw new Exception("Could not find a usable GL visual"); } IntPtr vinfo = GlitzAPI.glitz_glx_get_visual_info_from_format(dpy, scr, dformat); widget.DoubleBuffered = false; Gdk.WindowAttr attributes = new Gdk.WindowAttr(); attributes.Mask = widget.Events | (Gdk.EventMask.ExposureMask | Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask | Gdk.EventMask.EnterNotifyMask | Gdk.EventMask.LeaveNotifyMask | Gdk.EventMask.StructureMask); //attributes.X = widget.Allocation.X; //attributes.Y = widget.Allocation.Y; attributes.X = 0; attributes.Y = 0; attributes.Width = 100; attributes.Height = 100; attributes.Wclass = Gdk.WindowClass.InputOutput; attributes.Visual = new Gdk.Visual(gdkx_visual_get(XVisualIDFromVisual(vinfo))); attributes.Colormap = new Gdk.Colormap(attributes.Visual, true); attributes.WindowType = Gdk.WindowType.Child; Gdk.WindowAttributesType attributes_mask = Gdk.WindowAttributesType.X | Gdk.WindowAttributesType.Y | Gdk.WindowAttributesType.Visual | Gdk.WindowAttributesType.Colormap; widget.GdkWindow = new Gdk.Window(widget.ParentWindow, attributes, attributes_mask); widget.GdkWindow.UserData = widget.Handle; uint xid = gdk_x11_drawable_get_xid(widget.GdkWindow.Handle); attributes.Width = 100; attributes.Height = 100; IntPtr glitz_drawable = GlitzAPI.glitz_glx_create_drawable_for_window(dpy, scr, dformat, xid, (uint)attributes.Width, (uint)attributes.Height); ggd = new NDesk.Glitz.Drawable(glitz_drawable); IntPtr glitz_format = ggd.FindStandardFormat(FormatName.ARGB32); ggs = new NDesk.Glitz.Surface(ggd, glitz_format, (uint)attributes.Width, (uint)attributes.Height, 0, IntPtr.Zero); Console.WriteLine(ggd.Features); ggs.Attach(ggd, doublebuffer ? DrawableBuffer.BackColor : DrawableBuffer.FrontColor); //GlitzAPI.glitz_drawable_destroy (glitz_drawable); GlitzSurface gs = new GlitzSurface(ggs.Handle); return(gs); }