Пример #1
0
        private static void InitGL(System.Drawing.Imaging.PixelFormat pixelFormat, IntPtr hdc, out IntPtr hglrc)
        {
            Internal.System.Windows.Structures.PIXELFORMATDESCRIPTOR pfd = new Internal.System.Windows.Structures.PIXELFORMATDESCRIPTOR();

            hglrc = IntPtr.Zero;

            pfd.nSize      = (ushort)System.Runtime.InteropServices.Marshal.SizeOf(pfd);
            pfd.nVersion   = 1;
            pfd.dwFlags    = Internal.System.Windows.Constants.PFD_DRAW_TO_BITMAP | Internal.System.Windows.Constants.PFD_SUPPORT_OPENGL | Internal.System.Windows.Constants.PFD_SUPPORT_GDI;
            pfd.iPixelType = (byte)Internal.System.Windows.Constants.PFD_TYPE_RGBA;
            switch (pixelFormat)
            {
            case System.Drawing.Imaging.PixelFormat.Format16bppArgb1555:
            case System.Drawing.Imaging.PixelFormat.Format16bppGrayScale:
            case System.Drawing.Imaging.PixelFormat.Format16bppRgb555:
            case System.Drawing.Imaging.PixelFormat.Format16bppRgb565:
                pfd.cColorBits = 16;
                break;

            case System.Drawing.Imaging.PixelFormat.Format1bppIndexed:
                pfd.cColorBits = 1;
                break;

            case System.Drawing.Imaging.PixelFormat.Format24bppRgb:
                pfd.cColorBits = 24;
                break;

            case System.Drawing.Imaging.PixelFormat.Format32bppArgb:
            case System.Drawing.Imaging.PixelFormat.Format32bppPArgb:
                pfd.cColorBits = 32;
                break;
            }
            pfd.cDepthBits = 32;
            pfd.iLayerType = Internal.System.Windows.Constants.PFD_MAIN_PLANE;
            int format  = Internal.System.Windows.Methods.ChoosePixelFormat(hdc, ref pfd);
            int retval1 = Internal.System.Windows.Methods.SetPixelFormat(hdc, format, ref pfd);

            hglrc = Internal.OpenGL.Methods.glCreateContext(hdc);
        }
Пример #2
0
 public static extern int SetPixelFormat(IntPtr hdc, int iPixelFormat, ref Structures.PIXELFORMATDESCRIPTOR pfd);
Пример #3
0
 public static extern int ChoosePixelFormat(IntPtr hdc, ref Structures.PIXELFORMATDESCRIPTOR pfd);