Пример #1
0
        /// <summary>
        /// Get the <see cref="Glx.XVisualInfo"/> set on the specified X window.
        /// </summary>
        /// <param name="xWindow">
        /// The <see cref="IntPtr"/> that specifies the handle of the X window.
        /// </param>
        /// <returns>
        /// It returns the <see cref="Glx.XVisualInfo"/> set on <paramref name="xWindow"/>.
        /// </returns>
        private Glx.XVisualInfo GetVisualInfoFromXWindow(IntPtr xWindow)
        {
            Glx.XVisualInfo xVisualInfo;
            uint[]          windowFBConfigId = new uint[1];
            int             screen           = Glx.XDefaultScreen(_Display);

            // Get the FB configuration associated to the native window
            Glx.QueryDrawable(_Display, _WindowHandle, Glx.FBCONFIG_ID, windowFBConfigId);

            if (windowFBConfigId[0] == 0)
            {
                KhronosApi.LogComment("Glx.QueryDrawable cannot query Glx.FBCONFIG_ID. Query manually.");

                return(NativeWindow._InternalVisual);
            }

            unsafe {
                int[] attributes = new int[] {
                    Glx.FBCONFIG_ID, (int)windowFBConfigId[0],
                    0,
                };

                int[] choosenConfigCount = new int[1];

                IntPtr *choosenConfigs = Glx.ChooseFBConfig(_Display, screen, attributes, choosenConfigCount);
                if (choosenConfigCount[0] == 0)
                {
                    throw new InvalidOperationException("unable to find X Window visual configuration");
                }
                IntPtr configId = *choosenConfigs;

                xVisualInfo = Glx.GetVisualFromFBConfig(_Display, configId);

                Glx.XFree((IntPtr)choosenConfigs);
            }

            return(xVisualInfo);
        }