protected override void OnPaint(PaintEventArgs e)
{
RenderContext renderContext = this.renderContext;
if (renderContext == null)
{
base.OnPaint(e);
return;
}
stopWatch.Reset();
stopWatch.Start();
// Make sure it's our instance of openSharpGL that's active.
renderContext.MakeCurrent();
if (this.designMode)
{
try
{
DesignModeRender();
}
catch (Exception)
{
}
}
else
{
// If there is a draw handler, then call it.
DoOpenGLDraw(e);
}
// Blit our offscreen bitmap.
Graphics graphics = e.Graphics;
IntPtr deviceContext = graphics.GetHdc();
renderContext.Blit(deviceContext);
graphics.ReleaseHdc(deviceContext);
stopWatch.Stop();
{
ErrorCode error = (ErrorCode)OpenGL.GetError();
if (error != ErrorCode.NoError)
{
Debug.WriteLine(string.Format("{0}: OpenGL error: {1}", this.fullname, error));
}
}
this.FPS = 1000.0 / stopWatch.Elapsed.TotalMilliseconds;
}