-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGlobals.cpp
112 lines (86 loc) · 1.95 KB
/
Globals.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
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
#include "StdAfx.h"
#include "Globals.h"
UINT64 Time::m_iCounterStart = 0;
UINT64 Time::m_iCounterFrequency = 1;
double Time::m_fTimeElapsed = 0;
void Time::Init()
{
QueryPerformanceCounter((LARGE_INTEGER *)&m_iCounterStart);
QueryPerformanceFrequency((LARGE_INTEGER *)&m_iCounterFrequency);
}
void Time::Update()
{
UINT64 CurrentCounter;
QueryPerformanceCounter((LARGE_INTEGER *)&CurrentCounter);
CurrentCounter -= m_iCounterStart;
m_fTimeElapsed = CurrentCounter / (double)m_iCounterFrequency;
}
double Time::GetTimeElapsed()
{
return m_fTimeElapsed;
}
// Same thing, matches name the client might use?
double Time::GetTimeCurrent()
{
return m_fTimeElapsed;
}
HINSTANCE Globals::m_hInstance;
void Globals::Init(HINSTANCE hInstance)
{
m_hInstance = hInstance;
Time::Init();
}
HINSTANCE Globals::GetAppInstance()
{
return m_hInstance;
}
void Globals::GetScreenDimensions(long *plWidth, long *plHeight)
{
RECT ScreenRect;
GetWindowRect(GetDesktopWindow(), &ScreenRect);
*plWidth = ScreenRect.right - ScreenRect.left;
*plHeight = ScreenRect.bottom - ScreenRect.top;
}
void Globals::Cleanup()
{
}
GlobalResource::GlobalResource(LPCTSTR name, LPCTSTR type)
{
HRSRC hResourceInfo = FindResource(NULL, name, type);
if (hResourceInfo)
{
m_hResource = LoadResource(NULL, hResourceInfo);
if (m_hResource)
{
m_lpData = LockResource(m_hResource);
m_dwSize = SizeofResource(NULL, hResourceInfo);
}
else
{
m_lpData = NULL;
m_dwSize = 0;
}
}
else
{
m_hResource = NULL;
m_lpData = NULL;
m_dwSize = 0;
}
}
GlobalResource::~GlobalResource()
{
if (m_hResource)
{
FreeResource(m_hResource);
m_hResource = NULL;
}
}
LPVOID GlobalResource::GetData(void)
{
return m_lpData;
}
DWORD GlobalResource::GetSize(void)
{
return m_dwSize;
}