Closed NoelFB closed 6 years ago
Seems like someone is running the game in an absurdly high resolution, which XNA can't deal with out of the box.
Luckily, the person behind RomTerraria documented a hack to create RenderTarget2D
s larger than 4096x4096:
http://romsteady.blogspot.de/2013/11/xna-hack-create-rendertarget2d-greater.html
Problem: XNA's HiDef profile has a maximum Texture2D size of 4096x4096. RenderTarget2D has a backing Texture2D object, and this limitation is enforced at time of construction. Solution: Time to get a bit tricky with reflection. Limitations in XNA are all stored in Microsoft.Xna.Framework.Graphics.ProfileCapabilities, an internal class. Fortunately, they aren't constants... In your Initialize() function...
Assembly xna = Assembly.GetAssembly(typeof(GraphicsProfile)); Type profileCapabilities = xna.GetType("Microsoft.Xna.Framework.Graphics.ProfileCapabilities", true); if (profileCapabilities != null) { FieldInfo maxTextureSize = profileCapabilities.GetField("MaxTextureSize", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo hidefProfile = profileCapabilities.GetField("HiDef", BindingFlags.Static | BindingFlags.NonPublic); if (maxTextureSize != null && hidefProfile != null) { object profile = hidefProfile.GetValue(null); maxTextureSize.SetValue(hidefProfile.GetValue(null), MaxTextureSize); } }
He states that optimally, MaxTextureSize
should be determined using the DirectX API, but NextPOT(Math.Max(Engine.ViewWidth, Engine.ViewHeight))
should probably work fine, too, where NextPOT
returns the next higher power of two. This assumes that the backbuffer size <= the maximum supported texture size by the player's GPU.
Huh that's really interesting, thanks for the info! I think I'll likely just limit the texture size to the virtual game resolution (1920x1080) since everything else is handled that way too, but this is good for the future.
Fixed by clamping the texture size in the Breathing Minigame to 1920x1080
Shouldn't allow this to happen