Replace Wgl.GetCurrentDC with cached dc
authorStefanos A. <stapostol@gmail.com>
Wed, 18 Dec 2013 13:51:00 +0000 (14:51 +0100)
committerStefanos A. <stapostol@gmail.com>
Wed, 18 Dec 2013 13:51:00 +0000 (14:51 +0100)
 with

Source/OpenTK/Platform/Windows/WinGLContext.cs

index 9d4bf4c528066c71fae9813b98935bd947fb9f90..0e727df7d7cc558bc5fa3aa8b9907c256e09fd3b 100644 (file)
@@ -29,6 +29,7 @@ namespace OpenTK.Platform.Windows
     {
         static readonly object LoadLock = new object();
 
+        IntPtr device_context;
         bool vsync_supported;
 
         readonly WinGraphicsMode ModeSelector;
@@ -210,7 +211,7 @@ namespace OpenTK.Platform.Windows
             // side-effects (i.e. the old contexts can still be handled
             // using the new entry points.)
             // Sigh...
-            Wgl.MakeCurrent(window.DeviceContext, Handle.Handle);
+            MakeCurrent(window);
             Wgl.LoadAll();
 
             if (sharedContext != null)
@@ -284,9 +285,13 @@ namespace OpenTK.Platform.Windows
                     success = Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
                 }
 
+                device_context = wnd.DeviceContext;
+
                 if (!success)
+                {
                     throw new GraphicsContextException(String.Format(
                         "Failed to make context {0} current. Error: {1}", this, Marshal.GetLastWin32Error()));
+                }
             }
         }
 
@@ -435,11 +440,10 @@ namespace OpenTK.Platform.Windows
         {
             get
             {
-                return Wgl.GetCurrentDC();
+                return device_context;
             }
         }
 
-
         #endregion
 
         #endregion