FPS problem in my 2D engine

Started by
4 comments, last by MasterWorks 16 years, 1 month ago
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]
Advertisement
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

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Thank you,

I add this line in my code :

d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE ;

Now, I have got 3300 FPS in my program :)
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.
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.
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.

This topic is closed to new replies.

Advertisement