Пример #1
0
        public static IntPtr SelectFBConfig(IntPtr display, FramebufferFormat format)
        {
            List <int> visualAttribute = FramebufferFormatToVisualAttribute(format);

            IntPtr result = IntPtr.Zero;

            // TODO: make screen configurable?
            int screen = DefaultScreenLocked(display);

            int fbcount;

            unsafe
            {
                IntPtr *fbConfigs = GLX.ChooseFBConfig(display, screen, visualAttribute.ToArray(), out fbcount);

                if (fbcount > 0 && fbConfigs != null)
                {
                    result = *fbConfigs;

                    XFree((IntPtr)fbConfigs);
                }
            }

            return(result);
        }
Пример #2
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    MakeCurrent(null);

                    GLX.DestroyContext(_display, ContextHandle);
                }

                IsDisposed = true;
            }
        }
Пример #3
0
        public override void MakeCurrent(NativeWindowBase window)
        {
            if (_window != null && window != null && _window.WindowHandle.RawHandle == window.WindowHandle.RawHandle && IsCurrent)
            {
                return;
            }

            bool success;

            if (window != null)
            {
                if (!(window is GLXWindow))
                {
                    throw new InvalidOperationException($"MakeCurrent() should be used with a {typeof(GLXWindow).Name}.");
                }
                if (_display != window.DisplayHandle.RawHandle)
                {
                    throw new InvalidOperationException("MakeCurrent() should be used with a window originated from the same display.");
                }

                success = GLX.MakeCurrent(_display, window.WindowHandle.RawHandle, ContextHandle);
            }
            else
            {
                success = GLX.MakeCurrent(_display, IntPtr.Zero, IntPtr.Zero);
            }

            if (success)
            {
                _window = window;
            }
            else
            {
                throw new ContextException("MakeCurrent() failed.");
            }
        }
Пример #4
0
 public override void SwapBuffers()
 {
     GLX.SwapBuffers(DisplayHandle.RawHandle, WindowHandle.RawHandle);
 }