Benjamin
Benjamin

Reputation: 1253

Screen resolution keeps on getting reset back to default

I'm trying to learn Monogame right now by making some clones of some simple older games. I tried to set the screen resolution via the method described here:

How do I set the window / screen size in xna?

At first, a call to Console.WriteLine() reports that the resolution was changed successfully, but when I then run the program, I get the default 800x480. I added another call to Console.WriteLine() in the update() method to see what the resolution was, and it was reporting the 800x480.

What can I do to fix this? Do I need to set the resolution everytime in the update() method?

Upvotes: 0

Views: 102

Answers (1)

Davor Mlinaric
Davor Mlinaric

Reputation: 2027

Put initial resolution in your game constructor. Becuase if you put in Initalize, system first change resolution to default and then to your. With this code below system will change resolution only once. Don't have code now, but it should go like this:

public Game1()
{
     graphics = new GraphicsDeviceManager(this);
     graphics.PreferredBackBufferHeight = 600;
     graphics.PreferredBackBufferWidth = 800;
     // graphics.ApplyChanges(); <-- not needed
}

and then if you wish to change later, put in update funciton.

protected override void Update(GameTime gameTime)
{
    if(changeresolution){
         graphics.PreferredBackBufferHeight = 1600;
         graphics.PreferredBackBufferWidth = 1800;
         graphics.ApplyChanges();
         changeresolution = false;
    }
}

Upvotes: 1

Related Questions