Jump to content
  • Advertisement
Sign in to follow this  
jagguy2

low FPS count?

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

i am getting 5 frames per second FPS and i do draw a terrain 256X256. this seems way to big or is there a better way to cull this thing?

	float total=0,fps=0;
	float currTime  = (float)timeGetTime();
	float lastTime =  currTime;
	
	while( uMsg.message != WM_QUIT )
	{
		if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
		{ 
			TranslateMessage( &uMsg );
			DispatchMessage( &uMsg );
		}
        else
		
		    currTime  = (float)timeGetTime();
			
			//if ((currTime - lastTime)>=  16.0f)//60fps
			if ((currTime - lastTime)<=  1000)//60fps
			{
				fps++;	
				render(cam,terrain,total);	
			}
			else
			{
				total=fps;
				fps=0;
				lastTime = currTime;
			}

[Edited by - jagguy2 on January 10, 2008 1:08:46 AM]

Share this post


Link to post
Share on other sites
Advertisement
Yeah, you probably should optimize your terrain rendering. :)

Trying googling Frustum Culling for more information about basic culling. After that you might want to look for example Octree culling.

Share this post


Link to post
Share on other sites
i am loading in the terrain with without a mesh vertices but should i be using a mesh or x file to make it easier to handle?

Share this post


Link to post
Share on other sites
Far more details are necessary.

- Do other 3D applications run slowly? Maybe you have an old card and/or need to update your drivers?

- Take the render function out of your frame rate counting code. It doesn't need to be in there, and who knows, maybe it's throwing off your frame rate calculation somehow. That's just speculation, but regardless it doesn't need to be in there.

- The code you posted there doesn't tell us how you're rendering the terrain. When you say 256x256, do you mean quads, and are you rendering them individually? 65536 separate draw calls will cripple performance on even the fastest video card. It's always better to render a few large batches than a lot of small ones.

Share this post


Link to post
Share on other sites
The code you've posted looks incomplete. That makes it hard to tell what's exactly going on in there. Can you post your complete main loop (using the source tag to preserve formatting, as described in the GDNet Forums FAQ)?

Anyway, based on what I can see, this probably has nothing to do with suboptimal rendering code. You've got some pretty weird logic going on there. If at least 16 milliseconds have passed since the last frame, you're rendering the terrain. If not, you're setting lastTime to the current time (but you forget to do that when you are drawing the terrain). That causes your terrain to be rendered only during frames that take longer than 16 ms.


You should change your logic there. Remove the if-else clause, just render every frame. Then check your frametime at the end of each frame and calculate the framerate based on the frametime (fps = 1000 / frametime). Of course, it may vary somewhat, but that's ok. As long as you're getting framerates above a certain minimum everything should be just fine. Variabele framerates do mean that you'll have to make your gamecode time-based, but you'll likely have to do that anyway unless you can make sure your game runs at 60 fsp on all targeted systems.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!