diff --git a/src/OpenTK/Platform/Windows/API.cs b/src/OpenTK/Platform/Windows/API.cs
index 434d2987..3c716ba1 100644
--- a/src/OpenTK/Platform/Windows/API.cs
+++ b/src/OpenTK/Platform/Windows/API.cs
@@ -1421,9 +1421,8 @@ namespace OpenTK.Platform.Windows
}
}
-
[DllImport("gdi32.dll", SetLastError = true)]
- internal static extern IntPtr GetStockObject(int index);
+ internal static extern IntPtr GetStockObject(StockObjects fnObject);
[DllImport("gdi32.dll", SetLastError = true)]
internal static extern BOOL DeleteObject([In]IntPtr hObject);
@@ -3944,6 +3943,33 @@ namespace OpenTK.Platform.Windows
Baltic = 186,
}
+ ///
+ /// Identifiers for the GetStockObject method.
+ ///
+ internal enum StockObjects
+ {
+ WHITE_BRUSH = 0,
+ LTGRAY_BRUSH = 1,
+ GRAY_BRUSH = 2,
+ DKGRAY_BRUSH = 3,
+ BLACK_BRUSH = 4,
+ NULL_BRUSH = 5,
+ HOLLOW_BRUSH = NULL_BRUSH,
+ WHITE_PEN = 6,
+ BLACK_PEN = 7,
+ NULL_PEN = 8,
+ OEM_FIXED_FONT = 10,
+ ANSI_FIXED_FONT = 11,
+ ANSI_VAR_FONT = 12,
+ SYSTEM_FONT = 13,
+ DEVICE_DEFAULT_FONT = 14,
+ DEFAULT_PALETTE = 15,
+ SYSTEM_FIXED_FONT = 16,
+ DEFAULT_GUI_FONT = 17,
+ DC_BRUSH = 18,
+ DC_PEN = 19,
+ }
+
internal enum MapVirtualKeyType
{
/// uCode is a virtual-key code and is translated into a scan code. If it is a virtual-key code that does not distinguish between left- and right-hand keys, the left-hand scan code is returned. If there is no translation, the function returns 0.
diff --git a/src/OpenTK/Platform/Windows/WinGLNative.cs b/src/OpenTK/Platform/Windows/WinGLNative.cs
index 79d30b5a..460b24fe 100644
--- a/src/OpenTK/Platform/Windows/WinGLNative.cs
+++ b/src/OpenTK/Platform/Windows/WinGLNative.cs
@@ -727,7 +727,9 @@ namespace OpenTK.Platform.Windows
break;
case WindowMessage.ERASEBKGND:
- return new IntPtr(1);
+ // This is triggered only when the client area changes.
+ // As such it does not affect steady-state performance.
+ break;
case WindowMessage.WINDOWPOSCHANGED:
HandleWindowPositionChanged(handle, message, wParam, lParam);
@@ -934,6 +936,8 @@ namespace OpenTK.Platform.Windows
{
ExtendedWindowClass wc = new ExtendedWindowClass();
wc.Size = ExtendedWindowClass.SizeInBytes;
+ // Setting the background here ensures the window doesn't flash gray/white until the first frame is rendered.
+ wc.Background = Functions.GetStockObject(StockObjects.BLACK_BRUSH);
wc.Style = DefaultClassStyle;
wc.Instance = Instance;
wc.WndProc = WindowProcedureDelegate;