Search code examples
ubuntugraphicsmonodevelopviewportmonogame

Ubuntu - MonoGame static graphics.Viewport size


I'm running MonoGame in MonoDevelop under Ubuntu and doing some tutorials, but I'm constantly experiencing a problem with the size of

graphics.Viewport

Each time I build an app, it doesn't matter if it is windowed or fullscreen. The resolution doesn't matter also.

graphics.Viewport.Width
graphics.Viewport.Height

always return 800x480. Does anyone has any idea what's happening here?


Solution

  • So, I still don't know what was causing the problem, but I managed to avoid it. I was trying to get

    graphics.Viewport.Width
    graphics.Viewport.Height
    

    in a

    protected override void LoadContent()
    

    function. That's where the values were wrong. I tested some options and it came out that in the game class constructor, the values are right so what I did was simply I called a class attribute

    int[] WindowSize;
    

    and then in the main class constructor

    WindowSize = new int[] {graphics.GraphicsDevice.Viewport.Width,
                            graphics.GraphicsDevice.Viewport.Height};
    

    and that's what fixed my problem with the window size.