【问题标题】:How to enable antialiasing (4X MSAA) for AndroidGameView?如何为 AndroidGameView 启用抗锯齿 (4X MSAA)?
【发布时间】:2013-11-04 18:33:29
【问题描述】:

我有一个简单的 OpenGL 应用程序,我正在尝试为其启用抗锯齿 (4x MSAA)。我似乎无法弄清楚如何使用AndroidGameView 来做到这一点。

到目前为止,我一直通过 Developer Settings 菜单强制 4x MSAA 作为短期解决方案,但我希望能够以编程方式执行此操作。任何人都可以对此有所了解吗?

【问题讨论】:

  • 我也在Xamarin forums上发布了这个问题,但到目前为止没有收到任何回复。自从一个多月前有人问过before,我想我会试着问一下,但仍然没有回应。
  • 不确定它是否是您需要的,但GraphicsMode 有一个Samples 属性,用于设置要使用的 FSAA 样本数。
  • @Cheesebaron 感谢您的领导! GraphicsMode 只有一个用于 Samples 属性的 getter,所以我找到了一个解决方法,它作为答案发布在下面。

标签: mono xamarin.android xamarin opentk


【解决方案1】:

事实证明,以编程方式执行此操作的方法是在继承自 AndroidGameView 的类的 CreateFrameBuffer() 覆盖中设置 GraphicsMode 属性:

    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
    }

感谢Cheesebaron 引导我了解AndroidGameViewGraphicsMode 属性。

【讨论】:

  • 太棒了 :) 这将有助于将来参考。
猜你喜欢
  • 2011-09-23
  • 1970-01-01
  • 1970-01-01
  • 2014-02-18
  • 2012-12-23
  • 2021-05-20
  • 1970-01-01
  • 1970-01-01
  • 2013-12-10
相关资源
最近更新 更多