mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-08 10:10:00 +00:00
A DummyGLControl driver is now created when in DesignMode. Removes expensive GLContext initialization, and improves designer stability.
This commit is contained in:
parent
fc4e0f3698
commit
00463df2e8
|
@ -57,44 +57,14 @@ namespace OpenTK
|
||||||
this.SetStyle(ControlStyles.UserPaint, true);
|
this.SetStyle(ControlStyles.UserPaint, true);
|
||||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||||
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||||
|
|
||||||
this.Disposed += new EventHandler(GLControl_Disposed);
|
|
||||||
|
|
||||||
//Debug.Print("Creating GLControl.");
|
|
||||||
//this.CreateControl();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLControl_Disposed(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
//glControl.Context.Dispose();
|
|
||||||
//Application.ExitThread();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
/*
|
|
||||||
CreateParams @params;
|
|
||||||
protected override CreateParams CreateParams
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (@params == null)
|
|
||||||
{
|
|
||||||
@params = base.CreateParams;
|
|
||||||
//@params.ClassStyle = (int)
|
|
||||||
// (OpenTK.Platform.Windows.API.WindowClassStyle.OwnDC |
|
|
||||||
// OpenTK.Platform.Windows.API.WindowClassStyle.HRedraw |
|
|
||||||
// OpenTK.Platform.Windows.API.WindowClassStyle.VRedraw);
|
|
||||||
//@params.Style = (int)
|
|
||||||
// (OpenTK.Platform.Windows.API.WindowStyle.ClipChildren);
|
|
||||||
// OpenTK.Platform.Windows.API.WindowStyle.ClipSiblings);
|
|
||||||
//@params.ExStyle = OpenTK.Platform.Windows.API.ExtendedWindowStyle.
|
|
||||||
}
|
|
||||||
return @params;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#region --- Public Methods ---
|
#region --- Public Methods ---
|
||||||
|
|
||||||
|
#region public void CreateContext()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Forces the creation of the opengl rendering context.
|
/// Forces the creation of the opengl rendering context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -105,7 +75,11 @@ namespace OpenTK
|
||||||
throw new ApplicationException("Attempted to create GLControl more than once.");
|
throw new ApplicationException("Attempted to create GLControl more than once.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
if (this.DesignMode)
|
||||||
|
{
|
||||||
|
glControl = new DummyGLControl();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
switch (Environment.OSVersion.Platform)
|
switch (Environment.OSVersion.Platform)
|
||||||
{
|
{
|
||||||
|
@ -113,21 +87,16 @@ namespace OpenTK
|
||||||
case PlatformID.Win32Windows:
|
case PlatformID.Win32Windows:
|
||||||
glControl = new OpenTK.Platform.Windows.WinGLControl(this, new DisplayMode(Width, Height));
|
glControl = new OpenTK.Platform.Windows.WinGLControl(this, new DisplayMode(Width, Height));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlatformID.Unix:
|
case PlatformID.Unix:
|
||||||
case (PlatformID)128: // some older versions of Mono reported 128.
|
case (PlatformID)128: // some older versions of Mono reported 128.
|
||||||
glControl = new OpenTK.Platform.X11.X11GLControl(this);
|
glControl = new OpenTK.Platform.X11.X11GLControl(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PlatformNotSupportedException("Your operating system is not currently supported. We are sorry for the inconvenience.");
|
throw new PlatformNotSupportedException("Your operating system is not currently supported. We are sorry for the inconvenience.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Print("Could not create GLControl, error: {0}", e.ToString());
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.Visible = true;
|
this.Visible = true;
|
||||||
|
|
||||||
|
@ -135,6 +104,10 @@ namespace OpenTK
|
||||||
this.OnResize(EventArgs.Empty);
|
this.OnResize(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public void SwapBuffers()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Swaps the front and back buffers, and presents the rendered scene to the screen.
|
/// Swaps the front and back buffers, and presents the rendered scene to the screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -143,6 +116,10 @@ namespace OpenTK
|
||||||
Context.SwapBuffers();
|
Context.SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region public void MakeCurrent()
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Makes the underlying GLContext of this GLControl current. All OpenGL commands issued
|
/// Makes the underlying GLContext of this GLControl current. All OpenGL commands issued
|
||||||
/// from this point are interpreted by this GLContext.
|
/// from this point are interpreted by this GLContext.
|
||||||
|
@ -154,6 +131,8 @@ namespace OpenTK
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region --- Public Properties ---
|
#region --- Public Properties ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue