Permalink
Browse files

[GLControl] Warn when accessing GL properties on non-current context

  • Loading branch information...
1 parent c9a86a6 commit b9426006eff806b8947e6043b1718ac3dca3c02e @thefiddler thefiddler committed Jan 26, 2014
Showing with 12 additions and 0 deletions.
  1. +12 −0 Source/GLControl/GLControl.cs
View
12 Source/GLControl/GLControl.cs
@@ -139,6 +139,15 @@ IGLControl Implementation
}
}
+ [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 @@ public bool VSync
}
ValidateState();
+ ValidateContext("VSync");
return Context.SwapInterval != 0;
}
set
@@ -415,6 +425,7 @@ public bool VSync
}
ValidateState();
+ ValidateContext("VSync");
Context.SwapInterval = value ? 1 : 0;
}
}
@@ -468,6 +479,7 @@ public IWindowInfo WindowInfo
public Bitmap GrabScreenshot()
{
ValidateState();
+ ValidateContext("GrabScreenshot()");
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
System.Drawing.Imaging.BitmapData data =

0 comments on commit b942600

Please sign in to comment.