Shazen

I've found that I can easily change the TargetElapsedTime of my fixed step during game run, but the quickest I can set it to is 1 millisecond.

My computer is capable of more than 1000 FPS so I would like to set my game to variable in the middle of a run so that my frame counter will pick up an effectiveFPS & display it. then I switch back to fixed step so my play speeds are consistent.

This is just a tool while I code & create the game, it will not be utilized eventually. I just want to keep track of performance hits while I add things.

I find that game.IsFixedStep = false; does not do the trick, I'm still on fixed step (62 FPS & it is running that speed). Even calling Initialize(); after setting it to false does not work.

If I add game.TargetElapsedTime = TimeSpan.FromSeconds(0.001); my counter jumps right to 1000 and it is obvious I am running that fast.

So.. how to change from fixedStep to Variable & back in the middle of a game I thought maybe it needs to re-initialize like jumping from full screen to windowed does but calling Initialize(); after does not help. Are you stuck with one or the other




Re: XNA Framework changing from fixed to variable step in the middle of a game

Jim Perry

I don't understand what you're trying to do by switching back and forth. Are you saying your gameplay speed based on the frame rate I'd strongly suggest avoiding this.

You might also want to have a look at the GraphicsDeviceManager's SynchronizeWithVerticalRetrace property. Even with IsFixedStep set to false, your Draw is still only going to happen based on the card's refresh rate.






Re: XNA Framework changing from fixed to variable step in the middle of a game

Shazen

It is not about game play, I just want to monitor what my frame rate would be if the game loop did not have to wait for a tick event.

I like the fixed step concept so my game code is written by setting it to true with the step set to 0.016 (the default). I find as I add things to my game, I don't quite know how close I'm getting to that point where if I add more, the computer can not keep up with it and the frame rate will go below the 62 fps.

So I thought if I could momentarily (hook it to toggle by a key press) switch to variable, see how many frames it can do without having to wait for a tick event, I could keep an eye on the performance hits. (kind of benchmark my current game components).

if the GameTime structure could accomodate even one digit farther to the right of the decimal point on milliseconds (1/10th of a millisecond), I would do it by simple arithmetic.

"your quote"
your Draw is still only going to happen based on the card's refresh rate.
"end quote"

I understand the monitor refreshes per the card's set rate but it is my understanding that the draw call will re-draw the back buffer as often as it's told to and the back buffer is only presented to the monitor per the card's set rate. It is that draw call rate I'm trying to measure, not the monitor's refresh rate. Or are you saying that xna's draw() is tied somehow to the card's refresh rate








Re: XNA Framework changing from fixed to variable step in the middle of a game

Jim Perry

I should have clarified - The Draw event is tied to the SynchronizeWithVerticalRetrace. If it's set to true, as it is by default, Draw will only be called based on the refresh rate. If it's set to false, it'll be called as quickly as possible (based on whether the game has focus).




Re: XNA Framework changing from fixed to variable step in the middle of a game

Jon Watte

Fixed time step only affects the calls to Update, not to Draw (what I like to call "step" and "render," but there you have it).

Note that, if Draw gets called more often than Update, you will have to use some kind of interpolation or extrapolation within your drawing function, else you'll just draw multiple screens showing the same thing.






Re: XNA Framework changing from fixed to variable step in the middle of a game

Shazen

The SynchronizeWithVerticalRetrace property is what threw me. I did not realize it was tied to the draw call. But after experimenting, it obviously is.

It is working properly now, my toggle does the trick.

Thanks for the lesson.