CSharpGL.Win32.ChoosePixelFormat C# (CSharp) Метод

ChoosePixelFormat() приватный Метод

private ChoosePixelFormat ( IntPtr hDC, [ ppfd ) : int
hDC IntPtr
ppfd [
Результат int
        internal static unsafe extern int ChoosePixelFormat(IntPtr hDC,
            [In, MarshalAs(UnmanagedType.LPStruct)] PixelFormatDescriptor ppfd);

Usage Example

Пример #1
0
        /// <summary>
        /// This function sets the pixel format of the underlying bitmap.
        /// </summary>
        /// <param name="hDC"></param>
        /// <param name="bitCount">The bitcount.</param>
        protected virtual bool SetPixelFormat(IntPtr hDC, int bitCount)
        {
            //	Create the big lame pixel format majoo.
            var pixelFormat = new PixelFormatDescriptor();

            pixelFormat.Init();

            //	Set the values for the pixel format.
            pixelFormat.nVersion   = 1;
            pixelFormat.dwFlags    = (Win32.PFD_DRAW_TO_BITMAP | Win32.PFD_SUPPORT_OPENGL | Win32.PFD_SUPPORT_GDI);
            pixelFormat.iPixelType = Win32.PFD_TYPE_RGBA;
            pixelFormat.cColorBits = (byte)bitCount;
            pixelFormat.cDepthBits = 32;
            pixelFormat.iLayerType = Win32.PFD_MAIN_PLANE;

            //	Match an appropriate pixel format
            int iPixelformat = Win32.ChoosePixelFormat(hDC, pixelFormat);

            if (iPixelformat == 0)
            {
                return(false);
            }

            //	Sets the pixel format
            if (Win32.SetPixelFormat(hDC, iPixelformat, pixelFormat) == 0)
            {
                int lastError = Marshal.GetLastWin32Error();
                return(false);
            }

            return(true);
        }
All Usage Examples Of CSharpGL.Win32::ChoosePixelFormat