I am trying to resuscitate an old game project which is several years old. There are a few complicating factors. I am trying to build it in a Parallels VM running Windows 11 on a Mac M1, so the architecture is ARM.
The game crashes while it’s doing the initial graphics setup:
var fullScreen = true;
graphics.SynchronizeWithVerticalRetrace = false; // graphics is the XNA Framework GraphicsDeviceManager
device = graphics.GraphicsDevice;
graphics.GraphicsProfile = GraphicsProfile.HiDef;
Resolution.Init(ref graphics);
var ActualResolution = GameHelper.BestResolution(GraphicsAdapter.DefaultAdapter.SupportedDisplayModes); // chooses the most appropriate resolution as a Vector2D
var aspect = ActualResolution.X / ActualResolution.Y;
maxX = width; // these are fields on the base game class
maxY = (int)((float)width / aspect);
Resolution.SetVirtualResolution(maxX, maxY);
Resolution.SetResolution((int)ActualResolution.X, (int)ActualResolution.Y, fullScreen);
VirtualToActualResolutionRatio = new Vector2(maxX / ActualResolution.X, maxY / ActualResolution.Y);
graphics.PreferredBackBufferWidth = (int)ActualResolution.X;
graphics.PreferredBackBufferHeight = (int)ActualResolution.Y;
graphics.IsFullScreen = fullScreen;
graphics.ApplyChanges();
var pp = device.PresentationParameters;
screenRenderTarget = new RenderTarget2D(device, pp.BackBufferWidth, pp.BackBufferHeight, false, device.DisplayMode.Format, DepthFormat.Depth24); // this is where I get the exception
Full stack trace:
at Microsoft.Xna.Framework.Graphics.Texture2D.CreateTexture()
at Microsoft.Xna.Framework.Graphics.RenderTarget2D.CreateTexture()
at Microsoft.Xna.Framework.Graphics.RenderTarget2D.GenerateIfRequired()
at Microsoft.Xna.Framework.Graphics.RenderTarget2D..ctor(GraphicsDevice graphicsDevice, Int32 width, Int32 height, Boolean mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat)
at Magnetar.Magnetar.SetViewPortSize(Int32 width, Boolean reinit, GraphicsDeviceManager graphics) in \\Mac\Home\Documents\MonoMagnetar\MonoMagnetar\Magnetar.cs:line 2007
at Magnetar.Magnetar.Initialize() in \\Mac\Home\Documents\MonoMagnetar\MonoMagnetar\Magnetar.cs:line 1678
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at Magnetar.Program.Main() in \\Mac\Home\Documents\MonoMagnetar\MonoMagnetar\Program.cs:line 20
Any suggestions?