Exemple #1
0
        private GraphicsMode DescribePixelFormatARB(IntPtr device, int pixelformat)
        {
            GraphicsMode created_mode = null;

            // See http://www.opengl.org/registry/specs/ARB/wgl_pixel_format.txt for more details
            if (Wgl.SupportsFunction("wglGetPixelFormatAttribivARB"))
            {
                // Define the list of attributes we are interested in.
                // The results will be stored in the 'values' array below.
                int[] attribs = new int[]
                {
                    (int)WGL_ARB_pixel_format.AccelerationArb,

                    (int)WGL_ARB_pixel_format.RedBitsArb,
                    (int)WGL_ARB_pixel_format.GreenBitsArb,
                    (int)WGL_ARB_pixel_format.BlueBitsArb,
                    (int)WGL_ARB_pixel_format.AlphaBitsArb,
                    (int)WGL_ARB_pixel_format.ColorBitsArb,

                    (int)WGL_ARB_pixel_format.DepthBitsArb,
                    (int)WGL_ARB_pixel_format.StencilBitsArb,

                    (int)WGL_ARB_multisample.SampleBuffersArb,
                    (int)WGL_ARB_multisample.SamplesArb,

                    (int)WGL_ARB_pixel_format.AccumRedBitsArb,
                    (int)WGL_ARB_pixel_format.AccumGreenBitsArb,
                    (int)WGL_ARB_pixel_format.AccumBlueBitsArb,
                    (int)WGL_ARB_pixel_format.AccumAlphaBitsArb,
                    (int)WGL_ARB_pixel_format.AccumBitsArb,

                    (int)WGL_ARB_pixel_format.DoubleBufferArb,
                    (int)WGL_ARB_pixel_format.StereoArb,
                    0
                };

                // Allocate storage for the results of GetPixelFormatAttrib queries
                int[] values = new int[attribs.Length];

                // Get the format attributes for this pixel format
                if (!Wgl.WglGetPixelFormatAttribivARB(device, pixelformat, 0, (uint)attribs.Length - 1, attribs, values))
                {
                    Debug.Print("[Warning] Failed to detect attributes for PixelFormat: {0}.", pixelformat);
                }

                // Skip formats that don't offer full hardware acceleration
                WGL_ARB_pixel_format acceleration = (WGL_ARB_pixel_format)values[0];
                if (acceleration == WGL_ARB_pixel_format.FullAccelerationArb)
                {
                    // Construct a new GraphicsMode to describe this format
                    created_mode = new GraphicsMode(new IntPtr(pixelformat),
                                                    new ColorFormat(values[1], values[2], values[3], values[4]),
                                                    values[6],
                                                    values[7],
                                                    values[8] != 0 ? values[9] : 0,
                                                    new ColorFormat(values[10], values[11], values[12], values[13]),
                                                    values[15] == 1 ? 2 : 1,
                                                    values[16] == 1 ? true : false);
                }
            }
            return(created_mode);
        }