SFML community forums
Help => Graphics => Topic started by: AlekseiF on April 15, 2020, 11:03:02 pm
-
Hello everyone.
Sorry if failed to find a solution in the topics, I did try the search.
For the past 3 days I've been trying to find a reason for an issue I've been facing when running project in fullscreen mode.
I've tried to make a video and a screenshot, but for whatever reason that does not capture the artifacts, so I will try to explain that + add a screenshot with a small drawing.
Using .net SFML
I reduced everything in the project to have a sprite and a view for movement.
View is getting updated every frame and under certain conditions I move the view to have the effect of scrolling the world.
Whenever I set the fullscreen style:
_window = new RenderWindow(VideoMode.DesktopMode, "", Styles.Fullscreen);
I get strange behavior as if I see the previos frame buffer (kinda tried to draw that on screenshot)
What bothers me is that happens ONLY in fullscreen and I can not understand the reason behind that.
So I try to limit the framerate like this - update and render ~60 times a second:
private float _timePerFrame = 1.0f / 60.0f;
......................
while(_window.IsOpen)
{
_timeSinceLastUpdate += clock.Restart().AsSeconds();
if (_timeSinceLastUpdate > _timePerFrame)
{
_timeSinceLastUpdate -= _timePerFrame;
_window.DispatchEvents();
Update(_timePerFrame);
Render();
}
}
Now setting VSync makes the problem dissapear, but I would still like to understand why this happens.
My monitors refresh rate is 60 (well 59 by looking into display settings).
Any ideas are very appreciated.
-
Looks like screen tearing, and that's the reason why vertical synchronization exists.
-
Thank you for the answer. Does that mean, I should stop trying to find the reason and rely totally on VSync?
-
Read about "screen tearing" and you'll know the reason. And yes, rely on v-sync since this is exactly what it is for.
-
I did, I really did :) About GPU and Monitor refresh rate being out of sync.
Different approaches to fix that etc.
What I meant behind the "reason" - why I am seeing this in fullscreen only.
-
Because in fullscreen the GPU has "direct" access to the monitor. In windowed mode, the frame is first sent to the OS and then composited by the window manager with other things (windows, desktop) visible on screen before it is sent to the monitor. And the OS most likely takes care of v-sync ;)
-
:o I think I became a bit smarter now. Thank you so much!