SFML community forums
Help => General => Topic started by: kamac on March 30, 2015, 07:47:49 pm
-
Hey there.
I am using a 3rd party networking library, and I need to poll my packets as often as possible - framerate independent. But I also would like to have VSYNC enabled.
How do I go about that? When I turn VSYNC on, window.display() will block for a certain amount of time, and there's no way around it. I can't run my packet polling on a separate thread.
Should I just manually limit the framerate, and poll my packets independently? But that wouldn't be like turning VSYNC on - it'd be just limiting the framerate, right?
Cheers.
-
When there is enough time left in the current frame, you can poll more than once. Thus, you have different rates for polling and screen update.
See also here (http://en.sfml-dev.org/forums/index.php?topic=17816.0), some of the resources mentioned by Jesper Juhl address this issue, too.
-
I don't quite follow. I can't do anything during the time window.display() is called - and it will block for some milliseconds, for Vsync's sake. How can I poll my stuff during that time on the same thread? (By poll I mean call an object's member function, not poll keyboard events)
Didn't find the answer in the link you've linked.
-
Of course you can't do anything while display() blocks. But if there's extra time left in the current frame you can poll() your network stuff a few times before calling display().
It's all about keeping track of the time spent per frame and managing how it is used.
-
But if I turn VSync on, won't swapping buffers block by itself? Maybe I'm getting the wrong idea, but each time I turned it on, my framerate dropped to 60 FPS.
-
You were able to do other things between two display() calls, like game logic, so why shouldn't you be able to poll the network?
-
Uh,
But if I turn VSync on, won't swapping buffers block by itself? Maybe I'm getting the wrong idea, but each time I turned it on, my framerate dropped to 60 FPS.
Buffer swap occurs on .display().
@EDIT
Nevermind, figured it out.