Search code examples
c#openglopentk

Change GameWindow's GraphicsMode after creation


It's possible to specify the number of samples during the creation of GameWindow in OpenTK. In the code below samples is set to 4 (last argument of GraphicsMode constructor)

class MainWindow : GameWindow {
    MainWindow() : base(1920, 1080, new GraphicsMode(new ColorFormat(8), 8, 8, 4)) {
    }
}

Is it possible to change that number after the window was created? I'd like to do that to implement an option in the game settings for multisampling.


Solution

  • Short answer: No.

    Long answer: The GraphicsMode is used to create the underlying platform-specific window, and that's it; the GameWindow stores no information from it whatsoever, so it can't be modified. Said platform-specific window is stored in a ReadOnly variable, so you can't modify that either.

    From the brief amount of research I've done, it seems like OpenGL doesn't let you change the framebuffer's multisampling settings after it is created.

    If you want to change the GraphicsMode, you'll have to recreate your GameWindow after the user changes the settings (which is how the vast majority of games handle it).