Added workaround for issue #6

The issue is that some display devices report a BitsPerPel value of 0.
It is not clear whether this is a bug in WinDisplayDevice.cs or some
strange windows issue. The implemented workaround adds an entry to the
debug log and hardcodes BitsPerPel to 32 whenever this condition is
encountered. More investigation required.
This commit is contained in:
Stefanos A 2013-11-05 23:21:49 +01:00
parent 1a02457ddc
commit a4f125f16e

View file

@ -122,6 +122,8 @@ namespace OpenTK.Platform.Windows
if (Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.CurrentSettings, monitor_mode, 0) ||
Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.RegistrySettings, monitor_mode, 0))
{
VerifyMode(dev1, monitor_mode);
opentk_dev_current_res = new DisplayResolution(
monitor_mode.Position.X, monitor_mode.Position.Y,
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
@ -134,6 +136,8 @@ namespace OpenTK.Platform.Windows
mode_count = 0;
while (Functions.EnumDisplaySettings(dev1.DeviceName.ToString(), mode_count++, monitor_mode))
{
VerifyMode(dev1, monitor_mode);
DisplayResolution res = new DisplayResolution(
monitor_mode.Position.X, monitor_mode.Position.Y,
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
@ -163,6 +167,17 @@ namespace OpenTK.Platform.Windows
}
}
static void VerifyMode(WindowsDisplayDevice device, DeviceMode mode)
{
if (mode.BitsPerPel == 0)
{
Debug.Print(
"[Warning] DisplayDevice '{0}' reported a mode with 0 bpp. Please create a bug report at http://www.opentk.com",
device.DeviceName.ToString());
mode.BitsPerPel = 32;
}
}
#endregion
#region HandleDisplaySettingsChanged