/
ExampleScene.cs
40 lines (32 loc) · 1.17 KB
/
ExampleScene.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
using System;
using System.Diagnostics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Mathematics;
namespace Example {
/// Example class handling the rendering for OpenGL.
public static class ExampleScene {
private static readonly Stopwatch _stopwatch = Stopwatch.StartNew();
public static void Ready() {
Console.WriteLine("GlWpfControl is now ready");
GL.Enable(EnableCap.Blend);
GL.Enable(EnableCap.DepthTest);
GL.Enable(EnableCap.ScissorTest);
}
public static void Render() {
var hue = (float) _stopwatch.Elapsed.TotalSeconds * 0.15f % 1;
var c = Color4.FromHsv(new Vector4(hue, 0.75f, 0.75f, 1));
GL.ClearColor(c);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.LoadIdentity();
GL.Begin(PrimitiveType.Triangles);
GL.Color4(Color4.Red);
GL.Vertex2(0.0f, 0.5f);
GL.Color4(Color4.Green);
GL.Vertex2(0.58f, -0.5f);
GL.Color4(Color4.Blue);
GL.Vertex2(-0.58f, -0.5f);
GL.End();
GL.Finish();
}
}
}