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

Author Topic: Screen tearing - forcing vsync (move to the Window section?)  (Read 2577 times)

0 Members and 1 Guest are viewing this topic.

kdunee

  • Newbie
  • *
  • Posts: 6
    • View Profile
Screen tearing - forcing vsync (move to the Window section?)
« on: September 11, 2013, 07:26:00 pm »
Hi, I'm experiencing severe screen tearing in my application.
I've enabled the vertical synchronization with setVerticalSyncEnabled(true) but to no good effect (both on Windows 7 and Ubuntu 12.04).

However, after manually forcing v-sync in nVidia control panel the tearing miraculously disappeared.

Now here's the thing: I have GeForce GT 620M & Intel HD 3000 working in Optimus setup. On Linux I've disabled the nVidia card altogether to save power and on Windows as far I know Intel is still the default one if there's no existing profile for the application.
Forced v-sync works on both GPUs, setVerticalSyncEnabled(true) works on none.

Is there a stronger way to set v-sync programatically?
EDIT3: browsing around, looking for solution, I've established that we're using wglSwapIntervalEXT(1) to enable v-sync in SFML. Why this wouldn't work remains a puzzle to me ;)

And while I'm on it - does anyone know if the solution from http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf to select stronger GPU in Optimus setups works OK with SFML (I'm going to try it out eventually, but perhaps someone has a quick answer)?
EDIT2: Answering myself and anyone interested: yes, it works ;) I ended up with this code:
#ifdef __MINGW32__
#include <windows.h>
extern "C" {
 __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}
#endif // __MINGW32__
 

Thanks

EDIT: I think this should actually go to the Window section (http://en.sfml-dev.org/forums/index.php?board=6.0), sorry.
« Last Edit: September 11, 2013, 08:10:51 pm by kdunee »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Screen tearing - forcing vsync (move to the Window section?)
« Reply #1 on: September 11, 2013, 08:11:31 pm »
Is there a stronger way to set v-sync programatically?

No there isn't unless you write some very OS/GPU specific code (like you did). I recommend you avoid this route however.

As an alternate solutions you could avoid vsync and instead use RenderWindow.SetFrameRateLimit(...)  ;)
« Last Edit: September 11, 2013, 08:34:59 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

kdunee

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Screen tearing - forcing vsync (move to the Window section?)
« Reply #2 on: September 11, 2013, 08:33:56 pm »
Ok, thanks for the advice zsbzsb :)

I'll keep the code to utilise Optimus on Windows anyway, to use stronger GPUs when available.