migueltk's picture

As I can get the best MultiSample AntiAliasing PixelFormat for a GameWindow?

I just finished translating this demo and I just have to set this feature, the better MultiSample AntiAliasing PixelFormat.

Can anyone help?

Inline Images

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Check the example browser -> OpenTK -> GameWindow MSAA sample. In short, this will do the trick:

var game = new GameWindow(1024, 768, new GraphicsMode(32, 24, 0, 4)); // Request a GraphicsMode with 4x AA.
migueltk's picture

As I can know the maximum value that supports my graphics card?. In the example is initialized at 4x and my card supports 8x. I need to know the maximum value before instantiating the gamewindow.
As I can get this?

the Fiddler's picture

There is no API to retrieve the maximum AA mode yet. You can create GraphicsModes with increasing AA values until they repeat or fail:

var aa_modes = new List<int>();
try
{
    int aa = 0;
    do
    {
        var mode = new GraphicsMode(32, 0, 0, aa);
        if (!aa_modes.Contains(aa))
            aa_modes.Add(aa);
        aa += 2;
    } while (aa <= 32);
}

The maximum AA mode will be the one returned by aa_modes.Last().

migueltk's picture

I had to make a small modification but the code works, thank you very much.

            var aa_modes = new List<int>();
            int aa = 0;
            do
            {
                var mode = new GraphicsMode(32, 0, 0, aa);
                if (!aa_modes.Contains(mode.Samples))
                    aa_modes.Add(aa);
                aa += 2;
            } while (aa <= 32);

The demo can be downloaded from my website.