pontifikas's picture

GLControl's VSync Property doesn't seem to update the Context's VSync

Project:The Open Toolkit library
Category:bug report

I created a Control which Inherits directly from GLControl. Although in the designer I set VSync = false, the VSync is activated.
Only After I perform this.Context.VSync = false in the constructor of my Control, do I manage to deactivate it.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture


Thanks for the bug report. Which OS is this?

Edit: this is the code for GLControl.VSync:

                // 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;
                Context.VSync = value;

and inside the OnHandleCreated event:

            // 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;

Which means VSync should work even from the constructor (before the control handle is created). Can you please attach a simple test case?

pontifikas's picture


Actually the code below is all that matters to the construction of the control. I don't know if this is what you mean by test case.

Upon running the program, after having inserted a breakpoint at the line where I manualy set VSync to false, the value of this.Context.VSync is true;

I also inserted a dummy-override of OnHandleCreated (it doesn't exist in my code). It appears that VSync is true after Handle Creation.

public class GLighter_Screen : GLControl
        public GLighter_Screen(Control ParentControl)
            : base(OpenTK.Graphics.GraphicsMode.Default, Properties.Settings.Default.GLVerMaj, Properties.Settings.Default.GLVerMin, OpenTK.Graphics.GraphicsContextFlags.Default)
            this.ClientSize = new Size(ParentControl.Width, ParentControl.Height);
//At this point , "this.VSync" is true
            this.Context.VSync = false;
protected override void OnHandleCreated(EventArgs e)
            int i = 0;
            //I put a breakpoint here and VSync is true
            i = 1;

Actually "this.Context.VSync = false" is not necessary. " this.VSync = false;" does the trick. The problem must be that VS doesn't apply the default values of the property editor control. Only the changed ones.

Edit: My OS is Win7