Weird fullscreen glitch

Hi everyone, I’m learning Monogame and I’ve decided to create a Pong clone to learn the basics. I added the ability for the player to press F11 to toggle fullscreen on and off and I made it so that only each unique press of the key is counted to stop it from quickly switching back and forth whilst holding the key down.

previousF11 is set to false in the initialize method.

This code works perfectly as expected except for the very first time the game enters fullscreen mode. A frozen image of the game appears on my second monitor and the mouse is visible over the main game when this happens, even though it shouldn’t be as i have it disabled. The mouse actually disappears over the frozen image rather than the main game like its supposed to do.

If the user toggles the fullscreen on and off, then it works perfectly every other time from then on. It’s also fine if i launch the game in fullscreen from the beginning. It’s just when initially switching it to fullscreen from windowed mode. Sometimes i can recreate the issue later on in the program if I spam the F11 key.

It’s a bit difficult to explain so hopefully you understand what I mean. It’s not a major glitch by any means but it’s annoying and if anyone can figure it out I would very much appreciate it. Or do you think it could just be a problem with Windows and how it processes switching to fullscreen?

Yeah, I also noticed this exact problem you are describing. Having experienced the 90’s with CRT fullscreen switching that was always a heart twitching experience, I simply did not let this bother me. It’s probably related with how Windows manages things. You may try to maybe blank the screen for a short while during fullscreen switch that perhaps would make the problem less visible, or toggle hardware fullscreen mode to see which one works better.
However, I would not worry much about this.
Many users also expect artifacting during fullscreen switch, so it’s ok.

Okay thanks for letting me know. I was worried there as an issue with my code but if it’s just a windows issue then I won’t worry about it.

1 Like

No problem. I also want to congratulate you for starting small on this. Not like others (cough: me) that attempted way more complex games on their first try with MonoGame. You’re on a more safe and manageable path this way. Good luck!

Thank you :slight_smile: It’s going well so far. I’ve already finished my pong clone and I’m ready to move on to my next project now.

1 Like

In your graphics device manager you can set HardwareModeSwitch = false in your constructor.

From what I’ve read (and tested myself) this will tell Monogame to use a full screen borderless window instead of exclusive mode. It feels much nicer to switch full screen to window and may also help with your second monitor. In theory it costs you a tiny bit of performance.

In your game constructor you would do something like this:

public Game1()
{
_graphics = new GraphicsDeviceManager(this);
_graphics.HardwareModeSwitch = false;

I’m still new/learning as of a few weeks back, but hopefully this helps.

Hi sorry for the late response. I did try this and whilst it does fix the issue, it also stops the game window from scaling to the monitors resolution so I’ve decided to just not worry about it as it’s not too big of an issue.