mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 20:06:50 +00:00
Setting VSync mode should not force control creation. Fixes issue [#1071]: "Not firing Load event for GLControl."
This commit is contained in:
parent
3170c7aa0a
commit
a122fcd239
|
@ -50,6 +50,7 @@ namespace OpenTK
|
||||||
GraphicsMode format;
|
GraphicsMode format;
|
||||||
int major, minor;
|
int major, minor;
|
||||||
GraphicsContextFlags flags;
|
GraphicsContextFlags flags;
|
||||||
|
bool? initial_vsync_value;
|
||||||
|
|
||||||
#region --- Constructors ---
|
#region --- Constructors ---
|
||||||
|
|
||||||
|
@ -111,11 +112,11 @@ namespace OpenTK
|
||||||
|
|
||||||
if (!IsHandleCreated)
|
if (!IsHandleCreated)
|
||||||
CreateControl();
|
CreateControl();
|
||||||
|
|
||||||
if (implementation == null || context == null || context.IsDisposed)
|
if (implementation == null || context == null || context.IsDisposed)
|
||||||
RecreateHandle();
|
RecreateHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Protected Methods ---
|
#region --- Protected Methods ---
|
||||||
|
@ -129,7 +130,7 @@ namespace OpenTK
|
||||||
|
|
||||||
if (implementation != null)
|
if (implementation != null)
|
||||||
implementation.WindowInfo.Dispose();
|
implementation.WindowInfo.Dispose();
|
||||||
|
|
||||||
if (DesignMode)
|
if (DesignMode)
|
||||||
implementation = new DummyGLControl();
|
implementation = new DummyGLControl();
|
||||||
else
|
else
|
||||||
|
@ -141,6 +142,13 @@ namespace OpenTK
|
||||||
if (!DesignMode)
|
if (!DesignMode)
|
||||||
((IGraphicsContextInternal)Context).LoadAll();
|
((IGraphicsContextInternal)Context).LoadAll();
|
||||||
|
|
||||||
|
// Deferred setting of vsync mode. See VSync property for more information.
|
||||||
|
if (initial_vsync_value.HasValue)
|
||||||
|
{
|
||||||
|
Context.VSync = initial_vsync_value.Value;
|
||||||
|
initial_vsync_value = null;
|
||||||
|
}
|
||||||
|
|
||||||
base.OnHandleCreated(e);
|
base.OnHandleCreated(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +167,7 @@ namespace OpenTK
|
||||||
implementation.WindowInfo.Dispose();
|
implementation.WindowInfo.Dispose();
|
||||||
implementation = null;
|
implementation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnHandleDestroyed(e);
|
base.OnHandleDestroyed(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +178,7 @@ namespace OpenTK
|
||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
{
|
{
|
||||||
ValidateState();
|
ValidateState();
|
||||||
|
|
||||||
if (DesignMode)
|
if (DesignMode)
|
||||||
e.Graphics.Clear(BackColor);
|
e.Graphics.Clear(BackColor);
|
||||||
|
|
||||||
|
@ -294,11 +302,24 @@ namespace OpenTK
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (!IsHandleCreated)
|
||||||
|
return false;
|
||||||
|
|
||||||
ValidateState();
|
ValidateState();
|
||||||
return Context.VSync;
|
return Context.VSync;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
// The winforms designer sets this to false by default which forces control creation.
|
||||||
|
// However, events are typically connected after the VSync = false assignment, which
|
||||||
|
// can lead to "event xyz is not fired" issues.
|
||||||
|
// Work around this issue by deferring VSync mode setting to the HandleCreated event.
|
||||||
|
if (!IsHandleCreated)
|
||||||
|
{
|
||||||
|
initial_vsync_value = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ValidateState();
|
ValidateState();
|
||||||
Context.VSync = value;
|
Context.VSync = value;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +369,7 @@ namespace OpenTK
|
||||||
public Bitmap GrabScreenshot()
|
public Bitmap GrabScreenshot()
|
||||||
{
|
{
|
||||||
ValidateState();
|
ValidateState();
|
||||||
|
|
||||||
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
|
Bitmap bmp = new Bitmap(this.ClientSize.Width, this.ClientSize.Height);
|
||||||
System.Drawing.Imaging.BitmapData data =
|
System.Drawing.Imaging.BitmapData data =
|
||||||
bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
|
bmp.LockBits(this.ClientRectangle, System.Drawing.Imaging.ImageLockMode.WriteOnly,
|
||||||
|
|
Loading…
Reference in a new issue