OpenTk-如何启用多重采样

问题描述 投票:1回答:1

我正在尝试在OpenTK中实现多重采样,但是当我启用它时,两者之间没有区别没有抗混叠和多重采样。

No Antyaliasing

No Antyaliasing

Multisampling Enabled

Multisampling Enabled

这是OnRenderFrame中用于多重采样的代码:

protected override void OnRenderFrame(FrameEventArgs e)
    {
        base.OnRenderFrame(e);
        GL.Viewport(0, 0, Width, Height);
        GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
        GL.Enable(EnableCap.DepthTest);

        GL.Clear(ClearBufferMask.AccumBufferBit);

        shaders[activeShader].EnableVertexAttribArrays();

        int indiceat = 0;
        GL.Enable(EnableCap.Multisample);
        GL.Hint(HintTarget.MultisampleFilterHintNv,HintMode.Nicest);
        foreach (Volume v in objects)
        {
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, v.TextureID);
            GL.UniformMatrix4(shaders[activeShader].GetUniform("modelview"), false, ref v.ModelViewProjectionMatrix);

            GL.DrawElements(BeginMode.Triangles, v.IndiceCount, DrawElementsType.UnsignedInt, indiceat * sizeof(uint));
            indiceat += v.IndiceCount;
        }
}
c# opengl antialiasing opentk multisampling
1个回答
0
投票

您必须通过设置GraphicsMode来创建带有多样本缓冲区的窗口。构造GraphicsMode时设置GraphicsMode

例如:

GameWindow

在这种情况下,GameWindow的构造函数的第四个参数是样本数。

© www.soinside.com 2019 - 2024. All rights reserved.