SetPixelFormat() private method

private SetPixelFormat ( IntPtr dc, int format, PixelFormatDescriptor &pfd ) : bool
dc IntPtr
format int
pfd PixelFormatDescriptor
return bool
Ejemplo n.º 1
0
        // Note: there is no relevant ARB function.
        internal static void SetGraphicsModePFD(GraphicsMode mode, WinWindowInfo window)
        {
            Debug.Write("Setting pixel format... ");

            if (!mode.Index.HasValue)
            {
                throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
            }

            if (window == null)
            {
                throw new ArgumentNullException("window", "Must point to a valid window.");
            }

            PixelFormatDescriptor pfd = new PixelFormatDescriptor();

            Functions.DescribePixelFormat(window.DeviceContext, (int)mode.Index.Value,
                                          API.PixelFormatDescriptorSize, ref pfd);
            Debug.WriteLine(mode.Index.ToString());
            if (!Functions.SetPixelFormat(window.DeviceContext, (int)mode.Index.Value, ref pfd))
            {
                throw new GraphicsContextException(String.Format(
                                                       "Requested GraphicsMode not available. SetPixelFormat error: {0}", Marshal.GetLastWin32Error()));
            }
        }
Ejemplo n.º 2
0
        // Note: there is no relevant ARB function.
        internal static GraphicsMode SetGraphicsModePFD(WinGraphicsMode mode_selector,
                                                        GraphicsMode mode, WinWindowInfo window)
        {
            Debug.Write("Setting pixel format... ");
            if (window == null)
            {
                throw new ArgumentNullException("window", "Must point to a valid window.");
            }

            if (!mode.Index.HasValue)
            {
                mode = mode_selector.SelectGraphicsMode(
                    mode.ColorFormat, mode.Depth, mode.Stencil,
                    mode.Samples, mode.AccumulatorFormat,
                    mode.Buffers, mode.Stereo);
            }

            PixelFormatDescriptor pfd = new PixelFormatDescriptor();

            Functions.DescribePixelFormat(
                window.DeviceContext, (int)mode.Index.Value,
                API.PixelFormatDescriptorSize, ref pfd);

            Debug.WriteLine(mode.Index.ToString());

            if (!Functions.SetPixelFormat(window.DeviceContext, (int)mode.Index.Value, ref pfd))
            {
                throw new GraphicsContextException(String.Format(
                                                       "Requested GraphicsMode not available. SetPixelFormat error: {0}",
                                                       Marshal.GetLastWin32Error()));
            }

            return(mode);
        }
Ejemplo n.º 3
0
        private void SetGraphicsModePFD(GraphicsMode mode, WinWindowInfo window)
        {
            if (!mode.Index.HasValue)
            {
                throw new GraphicsModeException("Invalid or unsupported GraphicsMode.");
            }
            if (window == null)
            {
                throw new ArgumentNullException("window", "Must point to a valid window.");
            }
            PixelFormatDescriptor formatDescriptor = new PixelFormatDescriptor();

            Functions.DescribePixelFormat(window.DeviceContext, (int)mode.Index.Value, (int)API.PixelFormatDescriptorSize, ref formatDescriptor);
            if (!Functions.SetPixelFormat(window.DeviceContext, (int)mode.Index.Value, ref formatDescriptor))
            {
                throw new GraphicsContextException(string.Format("Requested GraphicsMode not available. SetPixelFormat error: {0}", (object)Marshal.GetLastWin32Error()));
            }
        }