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
|
//Wird extern vorm Rendern aufgerufen
public void Clear()
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
}
//Wird bei OnResize von OpenTK aufgerufen
public void RefreshView()
{
GL.Viewport(0, 0, Engine.CurrentWidth, Engine.CurrentHeight);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, Engine.CurrentWidth, Engine.CurrentHeight, 0, -1, 1);
}
//zeichne alle GameObjects
public void Render(Canvas canvas)
{
GL.PushMatrix();
GL.Translate(Position.X, Position.Y, 0);
GL.Scale(Size.X, Size.Y, 0);
GL.Rotate(Rotation.X, 1, 0, 0);
GL.Rotate(Rotation.Y, 0, 1, 0);
GL.Rotate(Rotation.Z, 0, 0, 1);
GameObject.GameObjects.Action(g =>
{
if (!g.IsActive)
return;
if (!Engine.Camera.Viewport.IntersectsWith(new RectangleF(g.Position.X, g.Position.Y, g.Size.X, g.Size.Y)))
return;
g.Components.Action(c =>
{
if (!c.IsActive)
return;
GL.PushMatrix();
GL.Translate(g.Position.X, g.Position.Y, 0);
GL.Scale(g.Size.X, g.Size.Y, 0);
GL.Rotate(g.Rotation.X, 1, 0, 0);
GL.Rotate(g.Rotation.Y, 0, 1, 0);
GL.Rotate(g.Rotation.Z, 0, 0, 1);
c.Render();
GL.PopMatrix();
});
});
GL.PopMatrix();
//Zeichnet das Canvas von Gwen (ein Control als Textbox ist eingebunden)
canvas.RenderCanvas();
}
|