GraphicsMode ChoosePixelFormatARB(IntPtr device, GraphicsMode mode)
{
GraphicsMode created_mode = null;
- if (Wgl.Delegates.wglChoosePixelFormatARB != null)
+ if (Wgl.SupportsExtension("WGL_ARB_pixel_format") &&
+ Wgl.Delegates.wglChoosePixelFormatARB != null)
{
List<int> attributes = new List<int>();
attributes.Add((int)WGL_ARB_pixel_format.AccelerationArb);
attributes.Add(mode.AccumulatorFormat.Alpha);
}
- if (mode.Samples > 0)
+ if (mode.Samples > 0 &&
+ Wgl.SupportsExtension("WGL_ARB_multisample"))
{
attributes.Add((int)WGL_ARB_multisample.SampleBuffersArb);
attributes.Add(1);
int[] format = new int[1];
int count;
- if (Wgl.Arb.ChoosePixelFormat(device, attributes.ToArray(), null, format.Length, format, out count))
+ if (Wgl.Arb.ChoosePixelFormat(device, attributes.ToArray(), null, format.Length, format, out count)
+ && count > 0)
{
created_mode = DescribePixelFormatARB(device, format[0]);
}
{
flags |= PixelFormatDescriptorFlags.STEREO;
}
- if (mode.Buffers > 1)
- {
- // On Win7 64bit + Nvidia 650M, no pixel format advertises DOUBLEBUFFER.
- // Adding this check here causes mode selection to fail.
- // Does not appear to be supported by DescribePixelFormat
- //flags |= PixelFormatDescriptorFlags.DOUBLEBUFFER;
- }
if (System.Environment.OSVersion.Version.Major >= 6 &&
requested_acceleration_type != AccelerationType.None)
valid &= GetAccelerationType(ref pfd) == requested_acceleration_type;
valid &= (pfd.Flags & flags) == flags;
valid &= pfd.PixelType == PixelType.RGBA; // indexed modes not currently supported
+ // heavily penalize single-buffered modes when the user requests double buffering
+ if ((pfd.Flags & PixelFormatDescriptorFlags.DOUBLEBUFFER) == 0 && mode.Buffers > 1)
+ dist += 1000;
valid &= Compare(pfd.ColorBits, mode.ColorFormat.BitsPerPixel, ref dist);
valid &= Compare(pfd.RedBits, mode.ColorFormat.Red, ref dist);
valid &= Compare(pfd.GreenBits, mode.ColorFormat.Green, ref dist);