Game Development Community

Frame rate capped at 30 fps???

by Grant Clarke · in Torque X 3D · 06/22/2009 (10:55 am) · 8 replies

I'm obviously missing something fundamental. My frame rate seems to be capped at 30 frames per second. I've commented out all my code that adds stuff to the scene so I'm just left with a blank screen and a frame rate counter. I've removed the terrain and sky from the starter level.

I've got the following lines in my settings file:

<UseFixedTimeStep>false</UseFixedTimeStep>

I've created a non Torque XNA windows game and I get a frame rate of 600fps as the app isn't doing anything.

Anybody have any ideas what I'm missing?

#1
06/22/2009 (11:45 pm)
Are you using the FPSText from the FPS demo?
#2
06/23/2009 (9:02 am)
I'm currently using a component I got from another project in case there is a TorqueX setting I've missed that may be effecting the way my TorqueX components get updated.

As an aside, I deployed to my xbox 360 yesterday and got a frame rate of around 100 fps. Just don't get why my windows project is so different.

Here is my frame counter code:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace StarterGame3D
{
    public class FrameRateCounter : DrawableGameComponent
    {
        ContentManager content;
        SpriteBatch spriteBatch;
        SpriteFont spriteFont, spriteFont2;

        int frameRate = 0;
        int frameCounter = 0;
        TimeSpan elapsedTime = TimeSpan.Zero;

        public FrameRateCounter(Game game)
            : base(game)
        {
            content = new ContentManager(game.Services);
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = content.Load<SpriteFont>("data/fonts/Font");
            spriteFont2 = content.Load<SpriteFont>("data/fonts/Font2");
        }

        protected override void UnloadContent()
        {
            content.Unload();
        }


        public override void Update(GameTime gameTime)
        {
            elapsedTime += gameTime.ElapsedGameTime;

            if (elapsedTime > TimeSpan.FromSeconds(1))
            {
                elapsedTime -= TimeSpan.FromSeconds(1);
                frameRate = frameCounter;
                frameCounter = 0;
            }
        }

        public override void Draw(GameTime gameTime)
        {
            frameCounter++;

            string fps = frameRate.ToString();

            spriteBatch.Begin();

            spriteBatch.DrawString(spriteFont, fps, new Vector2(11, 6), Color.Black);
            spriteBatch.DrawString(spriteFont, fps, new Vector2(12, 7), Color.Yellow);

            spriteBatch.End();
        }
    }
}
#3
06/23/2009 (12:17 pm)
Ok I can probably say that is the cause of your problem. You don't need Torque at all to use that component (which is an XNA component), and using it may interfere with the way Torque is running, though I can't guarantee that it certainly seems like the most probable cause to me.
#4
06/23/2009 (12:46 pm)
I just added that component to my game as a test, it seems to come only a frame or two behind my Torque based counter, so that might not be the problem, it might depend on what else you're doing.
#5
06/24/2009 (8:34 am)
That's thing. As far as I can tell I'm not doing anything else. I've stripped everything out. I did try using FPSText and got the same kind of frame rate.

Thanks for input anyway, Trent. Appreciate it :)
#6
06/25/2009 (1:08 am)
Welcome :)

At least it's working on your 360 ok!

Oh, did you turn SimulateFences on?
#7
06/27/2009 (2:42 pm)
I think that was on in the torqueSettings xml file. What does that do?
Not meaning to kill this thread, but laptop got stolen so I can't actually look at my code any more :(
#8
06/29/2009 (11:58 pm)
Man that sucks, sorry for your loss :(

The question was asked (and answered) in the TorqueX 2D forum here

http://www.garagegames.com/community/forums/viewthread/92965


The gist is that is stops the video card getting too far ahead of rendering than the update loop. I'm not quite sure how that happens (I know how the XNA version works though), but suffice to say, it seems to fix most framerate issues.