Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [SOLVED] Fullscreen artifacts  (Read 1990 times)

0 Members and 1 Guest are viewing this topic.

AlekseiF

  • Newbie
  • *
  • Posts: 4
    • View Profile
[SOLVED] Fullscreen artifacts
« 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.
« Last Edit: April 16, 2020, 11:49:31 am by AlekseiF »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Fullscreen artifacts
« Reply #1 on: April 16, 2020, 08:28:43 am »
Looks like screen tearing, and that's the reason why vertical synchronization exists.
Laurent Gomila - SFML developer

AlekseiF

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Fullscreen artifacts
« Reply #2 on: April 16, 2020, 08:32:10 am »
Thank you for the answer. Does that mean, I should stop trying to find the reason and rely totally on VSync?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Fullscreen artifacts
« Reply #3 on: April 16, 2020, 09:22:15 am »
Read about "screen tearing" and you'll know the reason. And yes, rely on v-sync since this is exactly what it is for.
Laurent Gomila - SFML developer

AlekseiF

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Fullscreen artifacts
« Reply #4 on: April 16, 2020, 10:07:45 am »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Fullscreen artifacts
« Reply #5 on: April 16, 2020, 10:57:36 am »
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 ;)
Laurent Gomila - SFML developer

AlekseiF

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Fullscreen artifacts
« Reply #6 on: April 16, 2020, 11:08:09 am »
 :o I think I became a bit smarter now. Thank you so much!

 

anything