I am using:


to determine the size of the canvas / stage for my window. This works well if I am in Windowed mode, but if I launched into fullscreen, it does not update to the new fullscreen size.

public HelloWorld()
    graphics = new GraphicsDeviceManager(this);

    int height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
    int width = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
    graphics.PreferredBackBufferHeight = height;
    graphics.PreferredBackBufferWidth = width;

    graphics.IsFullScreen = true;

    Content.RootDirectory = "Content";

Basically, I am setting the window to fullscreen in the constructor, but the Viewport does not get set to the new size (I also tried just setting to fullscreen without explicitly setting PreferredBackBuffer settings). I have tried manually setting the viewport size, but it appears to be null in the constructor.

So, is there a way to get the stage / screen bounds that I can draw to in a way that is consistent in both Windowed mode and fullscreen mode?

When I run, here is what I get:

enter image description here

(i.e. the viewport doesnt match the entire screensize).

Debugging this a bit more and the issue isnt that the viewport isnt being updated to the correct size (it is), but that it seems to render in a smaller space (see attached image). If I print out with the width / height of the viewport, it matches the full screen window, but when I draw at 0,0, it doesnt place it at the top left of the window).

Note, if I just set the window size to the dimensions of the screen, and DONT set it to fullscreen, then things work (i.e. the balls fill the screen)(see image below).

I can get it to work if I move the fullscreen call from the Constructor, and to Initialize. This works, but I am trying to figure out why it doesnt work when I call full screen in the constructor (and if that is the right place for me to make that call).

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.