Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable antialiasing (4X MSAA) for AndroidGameView?

I have a simple OpenGL application which I'm trying to enable antialiasing (4x MSAA) for. I can't seem to figure out how to do this using AndroidGameView.

So far I've been forcing 4x MSAA through the Developer Settings menu as a short term solution but I'd like to be able to do this programmatically. Can anyone shed some light on this?

like image 945
safwanc Avatar asked Dec 19 '25 20:12

safwanc


1 Answers

Turns out that the way to do this programmatically is to set the GraphicsMode property in the CreateFrameBuffer() override of your class inheriting from AndroidGameView:

    protected override void CreateFrameBuffer()
    {
        // Create a graphics context for OpenGL ES 2.0
        ContextRenderingApi = GLVersion.ES2;

        // Set the graphics mode to use 32bpp colour format, 24bpp depth, 8bpp stencil and 4x MSAA
        GraphicsMode = new GraphicsMode(new ColorFormat(32), 24, 8, 4); 

        // Create the frame buffer itself by calling the base class method
        base.CreateFrameBuffer();

        // Custom initialization code here
    }

Thanks to Cheesebaron for leading me down the path of looking into the GraphicsMode property of AndroidGameView.

like image 56
safwanc Avatar answered Dec 24 '25 12:12

safwanc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!