From b9426006eff806b8947e6043b1718ac3dca3c02e Mon Sep 17 00:00:00 2001 From: thefiddler Date: Sun, 26 Jan 2014 11:08:08 +0100 Subject: [PATCH] [GLControl] Warn when accessing GL properties on non-current context --- Source/GLControl/GLControl.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/GLControl/GLControl.cs b/Source/GLControl/GLControl.cs index 16acb68e..c2f616f6 100644 --- a/Source/GLControl/GLControl.cs +++ b/Source/GLControl/GLControl.cs @@ -139,6 +139,15 @@ namespace OpenTK } } + [Conditional("DEBUG")] + void ValidateContext(string message) + { + if (!Context.IsCurrent) + { + Debug.Print("[GLControl] Attempted to access {0} on a non-current context. Results undefined.", message); + } + } + void ValidateState() { if (IsDisposed) @@ -400,6 +409,7 @@ namespace OpenTK } ValidateState(); + ValidateContext("VSync"); return Context.SwapInterval != 0; } set @@ -415,6 +425,7 @@ namespace OpenTK } ValidateState(); + ValidateContext("VSync"); Context.SwapInterval = value ? 1 : 0; } } @@ -468,6 +479,7 @@ namespace OpenTK public Bitmap GrabScreenshot() { ValidateState(); + ValidateContext("GrabScreenshot()"); Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height); System.Drawing.Imaging.BitmapData data =