-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.h
62 lines (49 loc) · 1.53 KB
/
application.h
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
#pragma once
class Configuration;
struct Star
{
int xPos, yPos, zPos;
int lastX, lastY;
};
// Class for handling screensaver rendering logic. This class
// using GDI, but you can use another graphics renderer too
// like OpenGL or Direct3D. This class must be initialized on
// WM_CREATE message.
class Application
{
public:
static constexpr int TIMER_ID = 1;
Application() {}
Application(HWND hWnd, Configuration* config);
void Initialize(); // Initialize screen saver, called in constructor by default
void Deinitialize(); // Deinitialize screen saver, must be called in WM_DESTROY message
void Loop(); // Main screen saver loop, called every timer ticks
// Rendering specific methods
void SetCenterPosition(int x, int y);
// Called by DebugScreenSaverProc on debug mode
#ifdef _DEBUG
void Reload() { Deinitialize(); Initialize(); }
void Pause() { running = false; }
void Unpause() { running = true; }
#endif
private:
// Since screen saver always running until users interrupt it,
// this variable is useless in release mode
#ifdef _DEBUG
bool running;
#endif
// This methods called in main loop
void Update();
void Draw(HDC hdc);
void DrawBackground(HDC hdc);
// Framework specific variables:
// Screen saver config, Native window handle, and Random number generator
Configuration* config;
HWND hWnd;
std::mt19937_64 rndGen;
// Rendering specific variables
uint32_t centerX, centerY;
HFONT hFont;
static constexpr COLORREF BLACK = RGB(0, 0, 0);
static constexpr COLORREF WHITE = RGB(255, 255, 255);
};