public GLArea(int[] attrlist) { DoubleBuffered = false; dpy = gdk_x11_display_get_xdisplay (Gdk.Display.Default.Handle); Gdk.Visual visual = ChooseVisual (attrlist); XVisualInfo vi_template = new XVisualInfo (); vi_template.visual = gdk_x11_visual_get_xvisual (visual.Handle); vi_template.visualid = XVisualIDFromVisual (vi_template.visual); GdkVisual gvisual = Marshal.PtrToStructure(visual.Handle, typeof(GdkVisual)) as GdkVisual; Console.WriteLine (gvisual.depth); //vi_template.depth = (uint)GdkWindow.Depth; //TODO: correct? vi_template.depth = 16; //TODO: don't hardcode vi_template.screen = Gdk.Display.Default.DefaultScreen.Number; int nret = 0; XVisualInfo vi = XGetVisualInfo (dpy, (int) (VisualMask.IDMask | VisualMask.DepthMask | VisualMask.ScreenMask), vi_template, out nret); if (vi == null || nret != 1) Console.WriteLine ("Error"); ctx = glXCreateContext (dpy, vi, IntPtr.Zero, false); }
internal static extern XVisualInfo XGetVisualInfo(IntPtr display, int vinfo_mask, XVisualInfo vinfo_template, out int nitems_return);
internal static extern IntPtr glXCreateContext(IntPtr dpy, XVisualInfo vis, IntPtr shareList, bool direct);