EduGraf Programming: Get Going

Required Operating System

EduGraf runs on Windows, Linux and, with an issue, on Apple devices. The problem is that Apple only maintains WebGL in the browser, but not OpenGL for native applications. Fortunately, OpenTK has written an adapter. Thus, only on Apple devices, you need to add the following package to your project: dotnet add package OpenTK Unfortunately, there is currently an issue with the adapter that the displayed graphic only uses the lower left quarter of the window showing the EduGraf scene. Therefore, the framework currently lacks a Metal backend to run properly on Apple devices.

Development Setup

  1. Install the .NET 8 SDK.
  2. 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 .
  3. 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
  4. Rebuild your project.

Run EduGraf Test Program

The following code demonstrates a complete "hello triangle" program producing a plain triangle that can be viewed in 3D. This code serves as function test. Also, you get an idea how it looks like.
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, 2), Point3.Origin); var rendering = new TriangleRendering(graphic); using var window = new OpenTkWindow("Hello Triangle", graphic, 400, 400, camera.Handle); window.Show(rendering, camera); } }