-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
107 lines (81 loc) · 3.25 KB
/
Copy pathProgram.cs
File metadata and controls
107 lines (81 loc) · 3.25 KB
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
using OpenTK.Graphics.OpenGL4;
using OpenTK.Windowing.Desktop;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.GraphicsLibraryFramework;
using OpenTK.Mathematics;
namespace MyGame
{
public class Program
{
public static GameWindow window = new GameWindow(Window.gws, Window.nws);
public static Camera Camera = new Camera(Vector3.UnitZ * 550f);
public static Vector2i Size = new Vector2i(window.Size.X, window.Size.Y);
private static ImGuiController ?Imgui_controller;
private static Game ?game;
public static bool vsync = true;
public static bool fullscreen = false;
private static void Main()
{
window.Load += delegate
{
// DebugGL.InitDebug();
DebugGL.StartGlobal();
Camera.cameraSpeed = 50.0f;
Camera.TurboVel = 1.5f;
Imgui_controller = new ImGuiController(window.Size);
game = new Game();
};
window.RenderFrame += delegate(FrameEventArgs frameEventArgs)
{
Camera.cameraSpeed = Values.cameraVel;
Imgui_controller!.Update(Program.window, (float)frameEventArgs.Time);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
game!.RenderFrame();
ImGuiProgram.RenderFrame();
Imgui_controller.Render();
ImGuiController.CheckGLError("End of frame");
window.Context.SwapBuffers();
};
window.UpdateFrame += delegate(FrameEventArgs eventArgs)
{
var input = window.IsKeyPressed;
if (input(Keys.Escape))
window.Close();
if(input(Keys.F))
{
fullscreen = !fullscreen;
window.WindowState = fullscreen ? WindowState.Normal : WindowState.Fullscreen;
}
if(input(Keys.V))
{
vsync = !vsync;
window.VSync = vsync ? VSyncMode.On : VSyncMode.Off;
}
Clock.TimerUpdateFrame(eventArgs);
Camera.UpdateCamera();
game!.UpdateFrame();
};
window.Resize += delegate(ResizeEventArgs resizeEventArgs)
{
Size = resizeEventArgs.Size;
GL.Viewport(0, 0, resizeEventArgs.Size.X, resizeEventArgs.Size.Y);
Camera.UpdateSize(resizeEventArgs.Size);
Imgui_controller!.WindowResized(resizeEventArgs.Size);
game!.ResizedFrame();
};
window.MouseWheel += delegate(MouseWheelEventArgs mouseWheelEventArgs)
{
Camera.UpdateFov(ref mouseWheelEventArgs);
};
window.TextInput += delegate(TextInputEventArgs textInputEventArgs)
{
Imgui_controller!.PressChar((char)textInputEventArgs.Unicode);
};
window.Unload += delegate
{
game!.Dispose();
};
window.Run();
}
}
}