1

I'm trying to implement multisampling in OpenTK but when i enable it there's no diffrence between no antyaliasing and multisampling.

No Antyaliasing

No Antyaliasing

Multisampling Enabled

Multisampling Enabled

Here's a code in OnRenderFrame for multisampling :

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;
        }
}

1 Answer 1

2

You've to create a window with a multisample buffer, by setting the GraphicsMode. Set the GraphicsMode when the GameWindow is constructed:

e.g.:

public class OpenTK_Window
    : GameWindow
{
    OpenTK_Window(int width, int height, string title)
        : base(width, height, new GraphicsMode(32, 24, 8, 8), title,
    {}

    // [...]
}

In this case the 4th parameter to the constructor of GraphicsMode is the number of samples.

Sign up to request clarification or add additional context in comments.

2 Comments

I thought for a second you were wrong, because it wouldnt let me turn it off. But if i want to start without antialiasing i needed to disable it in rendering without it. Thank you very much.
I don't have such a thing like GraphicsMode In OpenTK 5.0 everything changed =(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.