Skip to main content
gamedev.net
🔒 Locked

irregular fps

Started by stewypeza Jun 2, 2006 at 12:27 PM 4 replies 900+ views
Original Post
stewypeza
stewypeza
Hi all. I have created an engine from scratch which is a renderer with some added game components. However i have a very irregualar fps count, its sort of like a sin wave. Over roughly a second the fps goes from 66 to 32 to 21 to 32 to 66 to 32 ... and so on. This is really wierd and is causing problems for my application. Does anyone know why this could be happening or how to get a smooth frame rate. Cheers Stuart Im using directx9 c++
vetroXL
vetroXL
Are you moving around the world? Do you have dynamic objects that are moving around the world? Basically, does the polygon count fluctuate alot? If so, you can solve that with frustum culling... I had a similar issue..
stewypeza
stewypeza
no its a static camera, with just objects in front of camera, no objects are even half on screen half off. Its not a game really, its a simple app. Nothing is moving except one object which rotates about the y axis. But because of this jumpiness in frame rate, the rotation looks really jumpy.
bangz
bangz
Hi Stewypeza,

How do you calculate your frame rate? You say it fluctuates within a second which leads me to assume your calculating the frame rate based on the amount of time it takes to render a single frame. From my experience your probably not doing anything wrong, you might be hitting a V-Sync boundary so that you have to wait until the next monitor refresh to begin rendering the next frame. It might be worth while calculating the frame rate as an average over a number of frames.

You can then use the calculated frame rate to smooth your rotation. If you know how may degrees you want to rotate per second then you just multiply this by 1.0f / Frame Rate for the amount you want to rotate per frame.



Richard.
stewypeza
stewypeza
I calculate the frame rate by finding the time difference between the render method being called. The code is shown below

	thisFrameTime = timeGetTime();	D3DXVECTOR3 DeckRot;	fpsTime = thisFrameTime - lastFrameTime;	fpsTime1 += fpsTime;	if (fpsTime1 > 150)	{		fps = 1000/fpsTime;		fpsTime1 = 0;	}	lastFrameTime = thisFrameTime;


The rotation is done in a similar way to how you suggested as shown below


	DeckRot = pVinyl[0].getRotation();	long FrameTime = thisFrameTime - lastFrameTime;	float speed = (float)(FrameTime/10000.0f);	DeckRot.y += speed*deck1rpm;	pVinyl[0].setRotation(DeckRot);


However as the frame rate drops to 20, the rotation of the objects visually looks really jumpy comapred to at 60 fps.

The frame rate always seems to be 66 max and 21 at the least as tho it is capped somehow but i havent implemented it to be restricted.

Also in theory even with 20 frames per second, an object rotating should still look smooth but in my app it looks very jumpy. Ive never come across something like this before and i am stumped. Any ideas or solutions much appreciated?
discman1028
discman1028
Try making everything in your framerate calculation 'float', just temporarily. Sometimes you think you're casting to float when you aren't. Since you're getting repetitive frame rates, I suspect that it's worth a shot to try all floats.
--== discman1028 ==--

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.