Skip to content

Conversation

ThomasMiz
Copy link
Contributor

Summary of the PR

Fixes #2000.

I'm having issues compiling ATM so I couldn't test this yet, and I'm out of time to work on this for today. I'll get back to this soon enough

@Perksey
Copy link
Member

Perksey commented Mar 24, 2024

I think the cause may be the change in video mode i.e. when it goes full screen, the swap interval is reset. My impression was that we had logic somewhere in there already to set SwapInterval after creation (or at least I have a feeling that I wrote that at some point in the last 5 years, possibly in DoRender where we try to detect if we’ve done it already maybe)

@ThomasMiz
Copy link
Contributor Author

Yes, in ViewImplementationBase.cs:

        public bool VSync
        {
            get => _optionsCache.VSync;
            set
            {
                _swapIntervalChanged = true;
                _optionsCache.VSync = value;
            }
        }
        public void DoRender()
        {
            [...]

            if ((delta >= _renderPeriod) || VSync)
            {
                [...]

                if (!IsContextControlDisabled && _swapIntervalChanged)
                {
                    GLContext?.SwapInterval(VSync ? 1 : 0);
                    _swapIntervalChanged = false;
                }

                [...]
            }
            
            [...]
        }

I was going to suggest we initialize _swapIntervalChanged to true, but...

        // Ensure we keep SwapInterval up-to-date
        private bool _swapIntervalChanged = true;

Not sure what's going on here

@Perksey
Copy link
Member

Perksey commented Mar 24, 2024

Setting _swapIntervalChanged to true probably makes sense in CoreInitialize. I think we should also set that to true whenever we change the window state or monitor.

Perksey added a commit that referenced this pull request Apr 15, 2024
@Perksey Perksey closed this in ff35bea Apr 23, 2024
@Perksey Perksey deleted the hotfix/set-vsync-on-glfw branch November 2, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

VSync setting is not being respected when switching WindowState inside Update event.
2 participants