Jump to content
  • Advertisement
Sign in to follow this  
Svenjamin

DirectX Fullscreen Unleashed

This topic is 4502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I have been working on a game with C++ and DirectX. When I run the game in windowed mode, it runs at about 150 fps, and according to windows task manager, uses only about 5-15% processing power, then when I switch to fullscreen, it used to do the same thing, 150 fps, 5-15% processing power. then one day, I ran it in fullscreen mode, and my computer decided to unleash all of its processing power onto this one app. and it runs at about 400 fps. does anyone know why it is doing this? is there a tutorial on how to make an accurate system to control the fps? thanks in advance, svenjamin

Share this post


Link to post
Share on other sites
Advertisement
Wild stab in the dark: It no longer has to devote any processing power to other running applications, the dektop, etc.

I've seen the GetTickCount() function used to control FPS. For example, your main render loop could look like this:

long fps = GetTickCount();
//Non-render-looping stuff
if (GetTickCount - fps >= 30)
{
fps = GetTickCount();
//Everything else goes here
}


This would cause your game to run at a constant 30 fps. Again, this post is nothing more than an educated guess.

Share this post


Link to post
Share on other sites
I´d turn that around. Normally you want a game to render as fast as possible, but update the game state based on "real-world" time, not on frames. So your main loop could look like this:

long lastUpdate = GetTickCount();
while(game_running)
{
long currentTime = GetTickCount();
if(currentTime - lastUpdate >= 50)
{
lastUpdate = currentTime;
//do game logic and state updates here
}
//render stuff here
}

Share this post


Link to post
Share on other sites
You didn't just switch the runtimes/compiler between debug/release mode did you? I've done that before by "accident" - got so used to my app running at ~50fps in debug+debug that I was surprised when it broke 100fps just by toggling to release+release.

Also, how are you timing the framerate? Above 100hz you can start getting timer inaccuracies - in which case you really can't rely on any performance information you might be getting from them.

I wouldn't recommend limiting your frame-rate - theres really no need to do that, and it's a great way of introducing some really nasty simulation and rendering errors.

hth
Jack

Share this post


Link to post
Share on other sites
Ok thanks for the replies.

To programwizard
I tried limiting it like you suggested, and I fooled around with it, but no matter what, it never would go above 60 fps.

To matches81,
I'll try you suggestion also, hopefully that will work.

To jollyjeffers,
I'll check the debug/release thing, I may have switched it, but I don't think I did, there is still only a Debug folder in the project directory, no Release folder. To my embarassment, there is no timing system in any of the few games that I have made. I tend to program the game around the speed at which it runs, instead of changing the speed to fit my game. Ex: in the game I am making now, most objects have a velocity that is either 1 or 0. because it runs fast enough that moving 1 pixel/s is a good amount. I really need to start establishing timing from now on.

Thanks for everyones help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!