0
\$\begingroup\$

All I could find about it is this question, but GraphicsMode alone doesn't enable anti-aliasing:

using System.Drawing;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;

class Program
{
    static void Main()
    {
        using (var window = new GameWindow(800, 60, new GraphicsMode(32, 24, 0, 8)))
        {
            window.Resize += (sender, e) => { GL.Viewport(window.Size); };
            window.RenderFrame += (sender, e) =>
            {
                GL.Clear(ClearBufferMask.ColorBufferBit);
                GL.Color3(Color.Red);
                GL.Begin(PrimitiveType.Triangles);
                GL.Vertex2(-1, 1);
                GL.Vertex2(-1, 0);
                GL.Vertex2(1, 0);
                GL.End();
                window.SwapBuffers();
            };
            window.Run();
        }
    }
}

enter image description here

\$\endgroup\$
  • 2
    \$\begingroup\$ Possible duplicate of MSAA/ CSAA / FXAA How to set the mode in OpenGL? \$\endgroup\$ – Rabbid76 Jan 14 '18 at 14:29
  • \$\begingroup\$ @Rabbid76, I think it should be much simpler in OpenTK. \$\endgroup\$ – Dmitry Fedorkov Jan 14 '18 at 14:41
  • \$\begingroup\$ Maybe it should, but it isn't. \$\endgroup\$ – Rabbid76 Jan 14 '18 at 14:54
  • \$\begingroup\$ @Rabbid76, then what's the point in this GraphicsMode constructor with int samples? Is there any documentation for this? \$\endgroup\$ – Dmitry Fedorkov Jan 14 '18 at 15:39
1
\$\begingroup\$

It's in the constructor of GraphicsMode:

new GameWindow(1280, 800, new GraphicsMode(new ColorFormat(8, 8, 8, 0), 24, // Depth bits 8, // Stencil bits 4 // FSAA samples ), "Title");

\$\endgroup\$
  • \$\begingroup\$ Did I use it wrongly? \$\endgroup\$ – Dmitry Fedorkov Jan 14 '18 at 15:36
  • 1
    \$\begingroup\$ Your code actually produces MSAA on my machine. I wonder why it doesn't work for you. \$\endgroup\$ – JBeurer Jan 14 '18 at 15:41
  • \$\begingroup\$ Wow, thanks. What OS and video card, and whether .NET or Mono? \$\endgroup\$ – Dmitry Fedorkov Jan 14 '18 at 15:46
  • 1
    \$\begingroup\$ Win7 64, .net, AMD hd6970 (mid range dedicated GPU from 5 years ago) \$\endgroup\$ – JBeurer Jan 14 '18 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.