How to draw with .NET Core?

You can use System.Drawing.Common NuGet package supports .net core however be aware some methods are not supported cross-platform.


You can actually use OpenGL to draw graphics with .NET Core, but it seems a bit cumbersome, if you are just committed to using C# and not .NET Core maybe Unity is a better option for you.

If you are trying to make a "desktop application" with GUI elements you can also look into Electron combined with TypeScript (which is somewhat similar to C#), this is how they made Visual Studio Code for example

EDIT: I just found another very interesting article (by the same guy I've mentioned in the comments) called Building a 3D Game Engine with .NET Core, I'm pretty sure you can get some inspiration out of that how to use OpenTK, Veldrid and ImGui.NET for drawing on screen.


You can use https://www.nuget.org/packages/OpenTK.NetStandard/

Instruction: how to create your first window for OpenGL graphics

  • dotnet new console
  • dotnet add package OpenTK.NetStandard
  • dotnet run
using System;
using OpenTK;
using OpenTK.Graphics.OpenGL;

namespace dotnet_opentk
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var window = new Window())
            {
                window.Run();
            }
        }
    }

    class Window : GameWindow
    {
        protected override void OnLoad(System.EventArgs e)
        {
            GL.ClearColor(0.1f, 0.2f, 0.3f, 1f);

            Console.WriteLine(GL.GetString(StringName.Version));
        }

        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit);
            SwapBuffers();
        }
    }
}