Hi,
i noticed a strange Fps problem.
I cant see the unlimited FPS in my “Monogame Windows OpenGL Project”. It stuck by 60 FPS
In the DirectX version it works fine.
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont font;
public Game1()
: base()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.SynchronizeWithVerticalRetrace = false;
IsFixedTimeStep = false;
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
font = Content.Load<SpriteFont>("Arial");
// TODO: use this.Content to load your game content here
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
int _total_frames = 0;
float _elapsed_time = 0.0f;
int _fps = 0;
protected override void Update(GameTime gameTime)
{
_elapsed_time += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
// 1 Second has passed
if (_elapsed_time >= 1000.0f)
{
_fps = _total_frames;
_total_frames = 0;
_elapsed_time = 0;
}
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
_total_frames++;
// TODO: Add your drawing code here
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null);
spriteBatch.DrawString(font, _fps.ToString(), Vector2.Zero, Color.Yellow);
spriteBatch.End();
base.Draw(gameTime);
}
}
Used the same code…
Just started with Monogame one week ago, it should be the lastest build.