-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
42 lines (31 loc) · 1.06 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
// example-0027
// earth sphere ( console program )
//
// - rotate earth sphere
InitAvalonia();
var w = GLWindow.Create(
onFocusedControlChanged: (split, AvaloniaGLControl, isInitial) =>
{
if (isInitial)
{
split.LoadViewLayout();
}
}
);
static string texturePathfilename(string name) => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "texture", name);
w.GLModel.BuildModel = (glCtl, isInitial) =>
{
if (!isInitial) return;
var glModel = glCtl.GLModel;
var glCtx = glCtl.GLContext;
glModel.Clear();
// lights loaded from layout.json ( saved using SHIFT+F2 )
// note: ambient is set to Black in order to make dark side effective
var earthTexture = new GLTexture2D(glCtx, SKBitmap.Decode(texturePathfilename("earth.jpg")));
var sphere = new UVSphere(center: Vector3.Zero, radius: 1);
// use of setUVTexture to map uv sphere texture coords
var fig = sphere.Figure(divisions: 20, setUVTexture: true);
fig.Texture2D = earthTexture;
glModel.AddFigure(fig);
};
w.ShowSync();