Sign in to follow this  

FPS problem in my 2D engine

This topic is 3572 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

Hi, I’m new on this forum. I'm begining a 2D engine with DirectX. But I have got a problem : the FPS is low even if no sprite is draw on the screen. 61 FPS for a black screen 78 FPS for drawing a map (512*512px) !!! It’s incredible. Also if I move the mouse on the application, the FPS are increasing ! I don’t know where is the problem. Thank you in advance. source and exe : http://c1rcus.free.fr/project.rar [Edited by - Circus on March 1, 2008 9:53:39 AM]

Share this post


Link to post
Share on other sites
Sounds like a VSYNC issue to me. 60 or 75 are quite common monitor refresh rates, the +1/+3 over that could just be a timing inaccuracy.

Try look up the D3DPRESENT_PARAMETERS::PresentationInterval and check for any override on your display driver's control panel.

Quote:
source and exe : http://c1rcus.free.fr/project.rar
As a general tip I wouldn't bother uploading your code. Post relevant fragments in 'source' tags as part of your thread if you think it'll be useful. Very few if anyone will download arbitrary source code or executables from the net [smile]


hth
Jack

Share this post


Link to post
Share on other sites
Thank you,

I add this line in my code :

d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE ;

Now, I have got 3300 FPS in my program :)

Share this post


Link to post
Share on other sites
Quote:

Also if I move the mouse on the application, the FPS are increasing !


In your message loop, you have

// if there is a message
// handle message

// else no message
// render frame

// update FPS counter



The FPS is getting recalculated whenever you draw a frame OR whenever you handle a message. Moving the mouse generates a lot of WM_MOUSEMOVE messages, and that is causing the FPS to be displayed higher than it really is.

Share this post


Link to post
Share on other sites
If I remember right, D3DPRESENT_INTERVAL_IMMEDIATE can cause tearing because it prompts the renderer to render immediately even before its ready to render the back buffer. You should use D3DPRESENT_INTERVAL_ONE and if your fps is low there might be a problem with your loop or how your handling your engine resources/systems/sub-systems.

Share this post


Link to post
Share on other sites
Quote:
Original post by Atom
before its ready to render the back buffer

I think it's more along the lines of, 'before the monitor is ready to RECEIVE the backbuffer' that can cause tearing; you're not going to end up with partial invalid frames being displayed. Instead, you might end up with partial valid frames (tearing).

That being said, there are a number of us who despise using VSYNC and this is definitely a common debate. Personally, I experience almost no tearing or other supposed drawbacks to having VSYNC off and get more fluid animation in almost all circumstances.

Share this post


Link to post
Share on other sites

This topic is 3572 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this