Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Window size

$
0
0

@MasterQuestMaster wrote:

I tried to follow the EmptyKeys UI tutorial to make a sample GUI.

In the process, I created the following event handler for graphics.PreparingDeviceSettings:

private void Graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
    this.nativeScreenWidth = this.graphics.PreferredBackBufferWidth;
    this.nativeScreenHeight = this.graphics.PreferredBackBufferHeight;

    this.graphics.PreferredBackBufferWidth = WINDOW_WIDTH; // const int = 1280
    this.graphics.PreferredBackBufferHeight = WINDOW_HEIGHT; // const int = 720
    this.graphics.PreferMultiSampling = true;
    this.graphics.GraphicsProfile = GraphicsProfile.HiDef;
    this.graphics.SynchronizeWithVerticalRetrace = true;
    this.graphics.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8;

    e.GraphicsDeviceInformation.PresentationParameters.MultiSampleCount = 16;
}

which is assigned like:

public WSOnlineGame()
{
    this.graphics = new GraphicsDeviceManager(this);
    this.graphics.DeviceCreated += Graphics_DeviceCreated;
    this.graphics.PreparingDeviceSettings += Graphics_PreparingDeviceSettings;
    this.Content.RootDirectory = "Content";
}

This is the other event handler:

private void Graphics_DeviceCreated(object sender, EventArgs e)
{
    //Ermöglicht Engine-Singleton
    Engine engine = new MonoGameEngine(this.GraphicsDevice, nativeScreenWidth, nativeScreenHeight);
}

From my understanding, setting the Width and Height should make the window the assigned size (1280 x 720). But when I start the program, it still runs on the default size of 800x480.
I verified that the code is called by setting a breakpoint in Visual Studio.

Google said to use ApplyChanges(), but apparently that causes an infinite loop when called inside PreparingDeviceSettings-Handler.

So why does the code not set my window size correctly? Is it not supported by my graphics card or something? Or am I overlooking something that also sets the size?

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles