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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#define MONO_CAIRO_DEBUG_DISPOSE
using System;
using System.Runtime.InteropServices;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;
using System.Diagnostics;
//using GGL;
using go;
using System.Threading;
namespace test
{
class GOLIBTest_Window : OpenTKGameWindow , IValueChange
{
#region IValueChange implementation
public event EventHandler<ValueChangeEventArgs> ValueChanged;
#endregion
#region FPS
int _fps = 0;
public int fps {
get { return _fps; }
set {
if (_fps == value)
return;
_fps = value;
if (_fps > fpsMax) {
fpsMax = _fps;
ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax));
} else if (_fps < fpsMin) {
fpsMin = _fps;
ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin));
}
if (ValueChanged != null)
ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", _fps));
}
}
string name = "testName";
public string Name {
get {
return name;
}
set {
name = value;
}
}
public int fpsMin = int.MaxValue;
public int fpsMax = 0;
void resetFps ()
{
fpsMin = int.MaxValue;
fpsMax = 0;
_fps = 0;
}
#endregion
public GOLIBTest_Window ()
: base(800, 600,"test")
{}
protected override void OnLoad (EventArgs e)
{
base.OnLoad (e);
LoadInterface("Interfaces/testWindow.goml");
LoadInterface("Interfaces/testWindow.goml");
// LoadInterface("Interfaces/testWindow.goml", out g);
// LoadInterface("Interfaces/testWindow.goml", out g);
// LoadInterface("Interfaces/testWindow.goml", out g);
// LoadInterface("Interfaces/testWindow.goml", out g);
// LoadInterface("Interfaces/testWindow.goml", out g);
CursorVisible = true;
}
private int frameCpt = 0;
protected override void OnUpdateFrame (FrameEventArgs e)
{
base.OnUpdateFrame (e);
fps = (int)RenderFrequency;
if (frameCpt > 200) {
resetFps ();
frameCpt = 0;
}
frameCpt++;
}
protected override void OnKeyDown (KeyboardKeyEventArgs e)
{
base.OnKeyDown (e);
this.Quit ();
}
void butQuitPress (object sender, MouseButtonEventArgs e)
{
DeleteWidget (sender as GraphicObject);
}
[STAThread]
static void Main ()
{
Console.WriteLine ("starting example");
using (GOLIBTest_Window win = new GOLIBTest_Window( )) {
win.Run (30.0);
}
}
}
}
|