1

I run a triple-monitor setup and I am working on a graphics demo in MonoGame that I decided (heck why not? let's give it the ability to maximize across all displays!) so I used this code:

 graphics.IsFullScreen = false;
        graphics.ApplyChanges();
        //get dimensions of box that will cover all displays and set window to it.
        int xPos = System.Windows.Forms.Screen.AllScreens.OrderBy(x => x.Bounds.X).Select(x => x.Bounds.X).First();
        int yPos = System.Windows.Forms.Screen.AllScreens.OrderBy(y => y.Bounds.Y).Select(y => y.Bounds.Y).First();
        form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        form.Location = new System.Drawing.Point(xPos, yPos);
        int xWidth = System.Windows.Forms.Screen.AllScreens.OrderByDescending(x => x.Bounds.X).Select(x => x.Bounds.X + x.Bounds.Width).First() - xPos;
        int yHeight = System.Windows.Forms.Screen.AllScreens.OrderByDescending(y => y.Bounds.Y).Select(y => y.Bounds.Y + y.Bounds.Height).First() - yPos;
        form.MaximumSize = new System.Drawing.Size(0, 0);

        form.Width = xWidth;
        form.Height = yHeight;
      //  graphics.PreferredBackBufferWidth = xWidth;
     //   graphics.PreferredBackBufferHeight = yHeight;
        graphics.ApplyChanges();
        Properties.Settings.Default.FakeFullScreen = true;
    }

and of course a 2nd function to undo it.

This worked fine when I had one of my monitors set above the others for testing, but when I set windows layout to place them all side-by-side (giving a resolution of 5760x1080) I was throwing an invalid parameter error on the graphics.ApplyChanges(). So I commented out the graphics code and set the form width manually and discovered that evidently I am not allowed to have a form wider than 4096 pixels.

Is there a way around this? I am open to all suggestions, including having more than one window side-by-side to draw to, but I would need some code to show me how to target a 2nd form.

Please and thank you.

John Lord
  • 1,941
  • 12
  • 27
  • I cannot help you with your specific question, but I would recommend to reconsider your requirement: A multi-monitor setup often results in a non-rectangular configuration overall. As I write this, I have a 1920x1200 monitor next to my 1920x1080 notebook screen. So if your algorithm works as you expect, a significant portion of your window would be invisible to me. – pniederh Aug 22 '19 at 05:33
  • 1
    that was expected. the non-visible areas wouldn't be drawn to. It's simply a graphics demo that draws patterns on the screen, and this is one of the expected ways of doing this to a non-standard monitor layout. My code not only returns the monitors, but their visible pixel range. – John Lord Aug 22 '19 at 13:10

1 Answers1

2

This is a DirectX 9/Windows Phone 7 limitation of texture sizes limited to 4096 x 4096 by the use of the "Reach Graphics Profile".

The final displayed image is a single texture of the composite of all spritebatches, the size cannot exceed the maximum texture size.

To correct the issue:

  1. Make sure your video card supports larger textures: run dxdiag.exe (most modern video cards do, given enough memory).
  2. Enable the "hidef" profile to allow full DX9, DX10, and DX11 modes.

To enable "Hidef", modify your Game1.cs constructor use this code:

public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.GraphicsProfile = GraphicsProfile.HiDef;
            graphics.ApplyChanges();
            // any additional code goes here
        }

The alternative is to use OpenGL, which ignores the graphics profile and uses the optimal version for your video card.

  • i can't "accept" your answer since it's wrong (it's code for xna) but it did point me in the direction i needed to go. Up-vote. The profile switching is possible but done totally differently. – John Lord Sep 04 '19 at 03:26
  • The code came directly from the MonoGame website. I made the assumption that the code given above would be placed after `//any additional code goes here` and thus `ApplyChanges()` would have been called(multiple times, although, only the last one is necessary). If the above code does not work(with your code under it), please let me know, and I will submit an issue with MonoGame. –  Sep 04 '19 at 22:57
  • ok well i don't know what i did but for thoroughness i retested your code again and it does in fact work. I must have put it in the wrong place originally. I will correct this heinous error and give you the credit. – John Lord Sep 05 '19 at 04:30