NRE -> GraphicsContextMissingException
authorStefanos A. <stapostol@gmail.com>
Thu, 3 Oct 2013 14:45:28 +0000 (16:45 +0200)
committerStefanos A. <stapostol@gmail.com>
Thu, 3 Oct 2013 14:45:28 +0000 (16:45 +0200)
Throw a GraphicsContextMissingException if GraphicsBindingBase.LoadAll() is called without a current GraphicsContext.

Source/OpenTK/Graphics/GraphicsBindingsBase.cs

index 8ca5997e035c28562069d274fb070f791d953048..29cbdbac57c9c28d85f7c2ea7675f9826051229d 100644 (file)
@@ -51,7 +51,10 @@ namespace OpenTK.Graphics
         /// </remarks>
         protected override IntPtr GetAddress(string funcname)
         {
-            return (GraphicsContext.CurrentContext as IGraphicsContextInternal).GetAddress(funcname);
+            var context = GraphicsContext.CurrentContext as IGraphicsContextInternal;
+            if (context == null)
+                throw new GraphicsContextMissingException();
+            return context != null ? context.GetAddress(funcname) : IntPtr.Zero;
         }
     }
 }