9 Application::Application()
14 , ctx(window.CreateContext())
21 GLContext::EnableVSync();
23 glClearColor(0.0, 0.0, 0.0, 1.0);
27 void Application::RunN(size_t n) {
28 Uint32 last = SDL_GetTicks();
29 for (size_t i = 0; i < n; ++i) {
30 Uint32 now = SDL_GetTicks();
31 int delta = now - last;
37 void Application::RunT(size_t t) {
38 Uint32 last = SDL_GetTicks();
39 Uint32 finish = last + t;
40 while (last < finish) {
41 Uint32 now = SDL_GetTicks();
42 int delta = now - last;
48 void Application::RunS(size_t n, size_t t) {
49 for (size_t i = 0; i < n; ++i) {
55 void Application::Run() {
57 Uint32 last = SDL_GetTicks();
60 Uint32 now = SDL_GetTicks();
61 int delta = now - last;
67 void Application::Loop(int dt) {
74 void Application::HandleEvents() {
76 while (SDL_PollEvent(&event)) {
80 interface.Handle(event.key);
82 case SDL_MOUSEBUTTONDOWN:
83 interface.Handle(event.button);
86 interface.Handle(event.motion);
89 interface.Handle(event.wheel);
95 switch (event.window.event) {
96 case SDL_WINDOWEVENT_FOCUS_GAINED:
99 case SDL_WINDOWEVENT_FOCUS_LOST:
100 window.ReleaseMouse();
102 case SDL_WINDOWEVENT_RESIZED:
103 cam.Viewport(event.window.data1, event.window.data2);
104 interface.Handle(event.window);
107 interface.Handle(event.window);
117 void Application::Update(int dt) {
118 interface.Update(dt);
122 void Application::Render() {
127 program.SetProjection(cam.Projection());
128 world.Render(program);
130 interface.Render(program);