EduGraf runs on Windows, Linux and, with currently some issue, on Apple devices. The problem on the latter is that Apple only maintains WebGL in the browser, but not OpenGL for native applications. Fortunately, OpenTK has written an adapter. But unfortunately, that adapter displays the graphic only in the lower left quarter of the window. To use this slightly flawed adapter, you need to explicitly add the following package to your project (for other devices, an explicit package reference is not needed):
dotnet add package OpenTK
Therefore, the framework currently lacks a Metal backend to run properly on Apple devices.
Development Setup
Install the .NET 9 SDK.
Install VisualStudio (Windows only) or the VS Code development environment and setup a C# project.
You can test the development setup by creating a new folder and open a terminal in that folder with the console commands:
dotnet new console
dotnet build
dotnet run
code .
In the C# project, install the EduGraf.OpenGL.OpenTK nuget package into your project via the package manager.
Alternatively you can use the console command:
dotnet add package EduGraf.OpenGL.OpenTK
Rebuild your project.
Run EduGraf Test Program
The following code demonstrates a complete "hello triangle" program producing a plain 3D-triangle. This code can serve as smoke test. Also, it gives you a first impression.
using EduGraf;
using EduGraf.Cameras;
using EduGraf.Geometries;
using EduGraf.Lighting;
using EduGraf.OpenGL.OpenTK;
using EduGraf.Tensors;
using EduGraf.UI;
public class TriangleRendering(Graphic graphic)
: Rendering(graphic, new Color3(0.2f, 0, 0.2f))
{
private static readonly float[] Positions = [
-0.5f,-0.5f, 0,
+0.5f,-0.5f, 0,
+0.0f, 0.5f, 0
];
public override void OnLoad(Window window)
{
var light = new AmbientLight(new(1, 1, 1));
var material = new UniformMaterial(0, 0, new Color3(1, 0, 0));
var shading = Graphic.CreateShading("emissive", material, light);
var geometry = Geometry.Create(Positions);
var surface = Graphic.CreateSurface(shading, geometry);
var triangle = Graphic.CreateVisual("triangle", surface);
Scene.Add(triangle);
}
}
static class Program
{
static void Main()
{
var graphic = new OpenTkGraphic();
var camera = new OrbitCamera(new Point3(0, 0, 3), Point3.Origin, Vector3.UnitY);
var rendering = new TriangleRendering(graphic);
using var window = new OpenTkWindow("Hello Triangle", graphic, 800, 800, camera);
window.Show(rendering);
}
}