Hi all,
I’m trying to apply resolution and anti-aliasing inside the game initialize method, but something is not working as excepted.
Platform: Windows 10
MonoGame version: 3.8.0.1641
With following code:
m_GraphicsDeviceManager.PreferredBackBufferWidth = 1200;
m_GraphicsDeviceManager.PreferredBackBufferHeight = 650;
m_GraphicsDeviceManager.IsFullScreen = false;
m_GraphicsDeviceManager.PreferMultiSampling = true;
m_GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.HiDef;
m_GraphicsDeviceManager.GraphicsDevice.PresentationParameters.MultiSampleCount = 4;
m_GraphicsDeviceManager.ApplyChanges();
I get this:
MultiSampleCount changed to 8, but should be 4.
After pressing the game window, drawer results change to:
Window size reset to default.
After move AA code to PreparingDeviceSettings event, as follow:
manager.PreferMultiSampling = true;
// manager.GraphicsProfile = GraphicsProfile.HiDef;
e.GraphicsDeviceInformation.GraphicsProfile = GraphicsProfile.HiDef;
e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = 4;
Results are:
GraphicsProfile do not change, Window size reset and MultiSampleCount is ok.
By using GraphicsProfile from manager instead of GDI, I get desired results:
manager.PreferMultiSampling = true;
manager.GraphicsProfile = GraphicsProfile.HiDef;
// e.GraphicsDeviceInformation.GraphicsProfile = GraphicsProfile.HiDef;
e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = 4;
But calling PreferMultiSampling and GraphicsProfile inside PreparingDeviceSettings event, internal applychanges flag is still true, ending up with a dirty GraphicsDeviceManager.
So at the end, I changes as follow:
m_GraphicsDeviceManager.PreferMultiSampling = true;
m_GraphicsDeviceManager.GraphicsProfile = GraphicsProfile.HiDef;
m_GraphicsDeviceManager.ApplyChanges();
m_GraphicsDeviceManager.PreferredBackBufferWidth = 1200;
m_GraphicsDeviceManager.PreferredBackBufferHeight = 650;
m_GraphicsDeviceManager.IsFullScreen = false;
m_GraphicsDeviceManager.ApplyChanges();
Calling ApplyChanges two times results are as excepted.
Is the last approach the correct one? if not, how should I handle this kind of scenario?