-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathProgram.cs
59 lines (44 loc) · 1.5 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! [example-0000]
namespace example;
// example-0000
// draw a triangle with 3 colors (one for each vertex)
//
// use gesture such as:
// - 'w' to toggle wireframe
// - ctrl right/left to change tilt
// - mouse wheel to zoom
// - 'z' to zoomfit
// - ctrl + x to show bbox
class Program
{
static void Main(string[] args)
{
// this must called for console application to enable Avalonia framework
// and must called before any other Avalonia control usage
InitAvalonia();
// create standalone Avalonia window for Silk.NET opengl rendering
var w = GLWindow.Create();
// define the GLModel build function
w.GLModel.BuildModel = (glCtl, isInitial) =>
{
// avoid to regen model if a full invalidate happens
if (!isInitial) return;
var glModel = glCtl.GLModel;
// clear the model
glModel.Clear();
var a = new Vector3(-50, -50, 0);
var b = new Vector3(50, -50, 0);
var c = new Vector3(0, 50, 0);
var va = new GLVertex(a, Color.Red);
var vb = new GLVertex(b, Color.Green);
var vc = new GLVertex(c, Color.Blue);
var tri = new GLTriangle(va, vb, vc);
// add triangle to the model
glModel.AddFigure(new GLTriangleFigure(tri));
glCtl.CameraView(CameraViewType.Top);
};
// show the gl window
w.ShowSync();
}
}
//! [example-0000]