-
Notifications
You must be signed in to change notification settings - Fork 0
/
Application.cpp
80 lines (68 loc) · 1.65 KB
/
Application.cpp
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
#include <iostream>
#include <stdexcept>
#include "Application.h"
#include "Window.h"
#include "math/Utility.h"
using namespace std;
namespace ST
{
Application::Application()
: lbutton_down(false)
{
graphics.SetCamera(&camera);
timer.Reset();
ShowWindow(MainWindow->GetHandle(), SW_NORMAL);
}
Application::~Application()
{
}
int Application::Run()
{
MSG msg;
while (true)
{
if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
break;
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
Sleep(1);
logic();
}
}
return msg.wParam;
}
//-------------- Draw a scene to the backbuffer --------------//
void Application::logic()
{
timer.Reset();
graphics.DrawScene();
}
void Application::KeyDown(int key)
{
}
void Application::LButtonDown(size_t x, size_t y)
{
}
void Application::LButtonUp(size_t x, size_t y)
{
}
void Application::MouseMove(size_t x, size_t y)
{
}
void Application::FileDropped(const string& filename, const string& ext)
{
if (ext == ".md5mesh")
{
model.LoadModel(filename + ext);
graphics.LoadModel(model.GetPositions(),
model.GetNormals(), model.GetIndices());
}
else MessageBox(0, TEXT("File isn't a model or an animation."),
TEXT("ERROR"), MB_OK);
}
}