using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace proj
{
public class game : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
public static SpriteBatch sprite_batch;
public static Texture2D texture;
public game()
{
graphics = new GraphicsDeviceManager(this);
}
protected override void Initialize()
{
graphics.PreferredBackBufferWidth = 300;
graphics.PreferredBackBufferHeight = 300;
graphics.ApplyChanges();
Content.RootDirectory = "Content";
sprite_batch = new SpriteBatch(GraphicsDevice);
texture = Content.Load<Texture2D>("a"); // 1 x 1, white
base.Initialize();
}
protected override void Update(GameTime game_time)
{
base.Update(game_time);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
sprite_batch.Begin();
if (gameTime.IsRunningSlowly)
{
sprite_batch.Draw(texture,
new Rectangle(50, 50, 200, 200), Color.OrangeRed);
}
sprite_batch.End();
base.Draw(gameTime);
}
}
}
For me the orange square is visible nearly all the time, however almost nothing is happening at all.
60 Update nothing and 60 Draw nothing, making 120 almost empty function calls that should occur and they have a whole second to do this in for the program to not be “running slowly”, yet gameTime.IsRunningSlowly returns True nearly all the time.
I’m sure my computer is fast enough to handle this better, whats going on? I need to be able to use gameTime.IsRunningSlowly, I can’t if it’s not working properly.
Do nothing. The problem will clear up all by itself magically!
Seriously though, IsRunningSlowly shouldn’t be lying to you. In a basic game project it should never be returning True unless system resources are scarce. If it’s returning True all the time then I’d recommend taking a look and seeing what other processes are running.
IsRunningSlowly is one of the XNA framework features that has been there from the start and while there is potential you’ve found some edge case that exposed some strange bug with it reporting incorrectly, it is unlikely.
I’d recommend re-starting the PC and then trying again. If the problem persists, you’re going to have to start examining what other processes are using system resources at start-up or evaluating your current hardware setup (and you shouldn’t need much for an empty game project to run at 60 FPS, the XNA default)