-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
76 lines (58 loc) · 1.85 KB
/
Main.cpp
File metadata and controls
76 lines (58 loc) · 1.85 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
#pragma once
#include "Functions.h"
int WINAPI WinMain(_In_ HINSTANCE hInstance, // **** Main Windows function **** //
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nShowCmd)
{
AllocConsole(); // initialize console window
FILE* fptr1;
FILE* fptr2;
FILE* fptr3;
freopen_s(&fptr1, "conin$", "r", stdin);
freopen_s(&fptr2, "conout$", "w", stdout);
freopen_s(&fptr3, "conout$", "w", stderr);
if (fptr1 == nullptr) MessageBox(0, L"Console Initialization Failed: stdin", L"Error", MB_OK);
if (fptr2 == nullptr) MessageBox(0, L"Console Initialization Failed: stdout", L"Error", MB_OK);
if (fptr3 == nullptr) MessageBox(0, L"Console Initialization Failed: stderr", L"Error", MB_OK);
Parse_data();
if (not InitializeWindow(hInstance, nShowCmd, screen_resolution.x, screen_resolution.y, windowed))
{
MessageBox(0, L"Window Initialization - Failed", L"Error", MB_OK);
return 0;
}
if (not InitDirectInput(hInstance))
{
MessageBox(0, L"Direct Input Initialization - Failed", L"Error", MB_OK);
return 0;
}
if (not InitializeDirect3d11App())
{
MessageBox(0, L"Direct3D Initialization - Failed", L"Error", MB_OK);
return 0;
}
Initialize_game();
print(runtime(NEWL + NEWL + "*** Entering main loop.. ***" + NEWL));
while (running) // **** Main Loop **** //
{
if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) // process window messages
{
TranslateMessage(&msg);
DispatchMessage(&msg); // @ WndProc()
}
if (paused == false)
{
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
Refresh_Input();
ImGui::NewFrame();
Process_Input();
Step();
Render();
}
}
print(runtime(NEWL + "*** Main loop terminated. ***" + NEWL));
CleanUp();
std::cin.ignore(); // keep console from closing
return msg.wParam;
}