From 94c02e827ac10cfcbb7da5beb6c279468e9e98f9 Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Thu, 3 Oct 2013 16:45:28 +0200 Subject: [PATCH] NRE -> GraphicsContextMissingException Throw a GraphicsContextMissingException if GraphicsBindingBase.LoadAll() is called without a current GraphicsContext. --- Source/OpenTK/Graphics/GraphicsBindingsBase.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Graphics/GraphicsBindingsBase.cs b/Source/OpenTK/Graphics/GraphicsBindingsBase.cs index 8ca5997e..29cbdbac 100644 --- a/Source/OpenTK/Graphics/GraphicsBindingsBase.cs +++ b/Source/OpenTK/Graphics/GraphicsBindingsBase.cs @@ -51,7 +51,10 @@ namespace OpenTK.Graphics /// 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; } } }