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
1 changed files with 27 additions and 6 deletions
|
@ -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 ---
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue