Posted: 23rd May 2023 2:46
So I have seen other people screens that can have 200 frames per sec and more set with v-sync.

So i need a good way to get there refresh rate and set the player speed and animations to the same speed no matter what there frame rates.

I can not set sync rate due to screen tearing so I need to find a better way to set speeds slower then normal or to half there frame rates I guess?

Timmer based movement I am guessing but not to sure?

Any suggestions would help.
Posted: 23rd May 2023 3:31
Timmer based movement

the (lone) search result for Timer based movement says it well.
Posted: 23rd May 2023 3:40
I'm not asking how to do timer based movement, I am asking if I should use that or something better if anything or anything at all?

Here is the issue.

When I use timer based movement my player skips a lot and you can see the jumps all the time and flickers as the time is not always constant.

When the timer is under 1 and jumps to over 1 you can see the player flicker or jump, I guess this will never happen with a pc that will always stay over 1?

Or should I do something else?

Is there a better way to get a constant timed movement?
Posted: 23rd May 2023 14:14
If timer based movement is done correctly, there should be only little tearing with SetSyncRate().
But maybe I'm used too much to G-Sync by now :/
Do you have a G-Sync monitor? If so, have you tried to switch off G-Sync? I've been experiencing some issues using G-Sync and Vulkan lately, see this thread:
https://forum.thegamecreators.com/thread/229121
Have you tried to use OpenGL instead of Vulkan?
Posted: 23rd May 2023 16:49
PSY

Hi I figured this out and it makes a lot of sense and this needs to be shared.

First i get the pcs refresh rate by setting SetVSync(1)

then in the loop I wait a few to get the correct pcs frame rate then change the frame rate to the monitors refresh rate, then turn vsync off.

+ Code Snippet
ScreenSpeed=ScreenFPS()
SetSyncRate(ScreenSpeed-5,1)
SetVSync(0)


I guess the computer get's its own refresh rate and the monitors get's it own and if they clash or equal they cause tearing and jumps.

So setting your monitors refresh rate to what vsync() collected already fixes all the issues.

I tested, that setting your refresh rate to 5 under the vsync() fixes all problems, even with timer based movement.

Edit:

Now you have to set that in your loop with a flag so it is not to repeat over and over, I added a timer to collect the frame rate for 100 mil seconds.
Posted: 23rd May 2023 17:52
Hey Game_Code_here,

Setting SetSyncRate() will automatically disable VSync, so you don't need to call SetVSync(0) after that.
I'm gonna try the -5 reduced sync rate, should I run into tearing problems. Thanks for the info!

Do you use OpenGL or Vulkan for rendering?
Using OpenGL fixed all my stuttering / tearing problems so far, even with SetSyncRate ( 0, 1 ) and using GetFrameTime() for time based movement...

PSY
Posted: 23rd May 2023 18:06
don't need to call SetVSync(0) after that


Yes you do and after you collect it you do need it any longer.

The render does not matter in screen tearing as it is a display problem not a render problem.

So no matter what you use to render it works.

I tested it on all renders.

So this is what I am doing, step by step.

In the main before anything

You might get tearing at first, but then nothing, what i do is set my screen to be black till it is set.

SetVSync(1)

then I set a timer in my loop

+ Code Snippet
if clearme<101
clearme=clearme+1
endif

if clearme=100
ScreenSpeed=ScreenFPS()
SetSyncRate(ScreenSpeed-5,1)
SetVSync(0)
clearme=101
endif


So I am getting the vsync then setting my sync rate to that then setting my vsync off. No tearing.
Posted: 23rd May 2023 19:37
I do have G-Sync, and as soon as I switch from Vulkan to OpenGL, the tearing completely disappears. I'm using SetSyncRate ( 0,1 ) and GetFrameTime().
It's just strange that you need to set SetVSync(0) after SetSyncRate(), because help says :
Using SetSyncRate will automatically turn VSync off since the two commands would fight each other for control of the frame rate.


I'm gonna do some test on my other system which doesn't support G-Sync.

Thanks again for the explanation!
Posted: 23rd May 2023 20:28
Well i do not have GSync and others will not have it so I would not use it for building or testing.

Use native commands for others.

Turn that off and try to use what i just showed you, it works on every device I tried.

One last thing to worry about.
Posted: 23rd May 2023 21:52
I always test with and without G-Sync so that I am on the safe side.
I also never use Vulkan as the default renderer, as the OpenGL renderer runs more reliably for me.
If I ever have problems with tearing, I will definitely try your approach.
Posted: 23rd May 2023 21:54
The only thing I noticed is it does not always load with the same frame rate in every place I load into, So You will have to make sure where your player loads gets the best frame rate or full frame rates.