3

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?

safwanc
  • 3,351
  • 2
  • 15
  • 20
  • I also posted this question on the [Xamarin forums](http://forums.xamarin.com/discussion/9726/how-to-enable-4x-msaa-for-androidgameview#latest) but it received no responses so far. Thought I'd try asking on SO since its been asked [before](http://forums.xamarin.com/discussion/8248/androidgameview-antialiasing) over a month ago but still no response. – safwanc Nov 04 '13 at 18:35
  • 1
    Not sure if it is what you need, but `GraphicsMode` has a `Samples` property, which sets how many FSAA samples to use. – Cheesebaron Nov 05 '13 at 11:24
  • @Cheesebaron Thanks for the lead! `GraphicsMode` only has a getter for the `Samples` property so I found a workaround which is posted as the answer below. – safwanc Nov 05 '13 at 18:43

1 Answers1

3

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.

Community
  • 1
  • 1
safwanc
  • 3,351
  • 2
  • 15
  • 20