• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Game speed is set to the Monitor Refresh?

Rafael_Lima

Member
So... my computer has a problem that when I set it to a 1080p resolution, my monitor actually goes to a 1080i setting with a 30hz update. (This seems to be a common issue with AMD cards and HDMI output and I am still trying to figure it out).

Thing is... when I test my 60fps game with this setting, the game actually runs at half speed! I obviously expected the DISPLAY to update at 30hz... but not game logic! Is the game logic attached to the monitor refresh rate? And if that's the case, if the game is ran at a 120 hz or 144hz display will it get ultra fast?
 
Last edited:

Nocturne

Friendly Tyrant
Forum Staff
Admin
The game won't (or shouldn't) run extra fast at HZ over the game speed... it'll be capped at the game speed. However, you have to keep in mind that GameMaker is single-threaded and all events occur in a set order, so if the draw event is capped at 30FPS, so is the step event which means that the game will play at 30FPS. Basically, the game will always attempt to run at the game speed set (normally 60fps) but if the refresh rate is lower then it'll be capped at the lower speed.
 

Rafael_Lima

Member
Actually, I figured out a "way" to make it work. I must admit I don't know if that's how it used to work on older Game Maker versions before Studio 2, if back then it would slowdown the game running at lower display refresh rates, as I had never tested any GM8.1 or GMS1 game on any display that wasn't 60hz.

But it seems the command display_set_timing_method let me choose if the game should update its logic based on the refresh rate of the display or what the room speed (or game speed) is set, while "sleeping" after a frame ends before the the vblank. At least that's what I understood from what's written on the manual and then testing the command. The manual isn't exactly very clear about how it works, and I have no idea of what is the "sleep margin" it cites, nor what will happen if the game actually misses a vblank when processing a frame ( Frameskip + slowdown I am guessing)...

But at least the game ran at the correct speed when the display was at 30hz. Obviously the display was updating at just 30hz, but the game logic kept running at 60 fps.

I am also really curious to what may happen when the game update is attached to the display refresh and the game can't process all its logic in a frame... does the game updates the display ANYWAY? That would be really weird, it would keep the framerate constant, but could cause all kind of strange behaviour in the game.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay, so the sleep margin...

if you set the game FPS to 60 and the real FPS runs much faster, there's an amount of time that the game has to wait before rendering the next frame. Normally you would want to issue the OS "Sleep()" command for the time remaining so the OS gets that time back and can save power, battery and run other things.

However... Sleep() isn't very accurate (on windows at least). So this value lets you tell GameMaker the minimum value it'll ever try to sleep for in ms. If the time left is >1ms (if that's whats set in the options) then it'll try to use a sleep() for that amount of time. This gives the maximum time back to the OS,

However....If it spends most of it's time sleeping, with Power Saving etc being what it is these days, windows suddenly thinks the machine isn't that busy and so starts to power down the CPU and graphics card. By raising this number (to 10 for example), this means it'll spend more of it's time in a tight loop waiting for the next frame. This will give a more accurate timing, but will also burn more CPU time and power. This will satisfy Power Saving (as you're machine is now doing something most of the time), but on machines with batteries - laptops and mobiles, this can cause fans to come on, and power to drain quicker than normal. This is why the value was made user controllable. The higher the number, the more time it'll spend spinning and waiting, but the more accurate it'll be.

So, by switching the timing method from vsync to sleep margin, you are using the sleep margin timer to govern refresh rates, which means you should ALSO ensure the sleep margin is somewhere between 10 and 20ms. As for the update being tied to the refresh rate, if the real FPS drops below the game FPS, you'll simply get lag. Keep in mind that the framerate and the game logic are absolutely linked and so you can't update one without updating the other. If the game lags, then the display will lag too causing stuttering etc...
 
Top