-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
96 lines (79 loc) · 2.16 KB
/
main.cpp
File metadata and controls
96 lines (79 loc) · 2.16 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <d3d11.h>
#include <dxgi.h>
#include <d3dcompiler.h>
#include <string>
#include "engine/core/Logger.h"
#include "engine/platform/Window.h"
#include "engine/core/input.h"
#include "engine/core/Engine/Engine.h"
// Lets Create the Window proc:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg)
{
case WM_KEYDOWN:
{
input::keys[wParam] = true;
Logger::log(
LogLevel::Debug,
"Input",
std::string("Key DOWN: ") + std::to_string(wParam)
);
return 0;
}
case WM_KEYUP:
{
input::keys[wParam] = false;
Logger::log(
LogLevel::Debug,
"Input",
std::string("Key UP: ") + std::to_string(wParam)
);
return 0;
}
case WM_MOUSEMOVE:
{
input::mouseX = GET_X_LPARAM(lParam);
input::mouseY = GET_Y_LPARAM(lParam);
return 0;
}
case WM_LBUTTONDOWN:
{
input::mouseLeftDown = true;
return 0;
}
case WM_LBUTTONUP:
{
input::mouseLeftDown = false;
return 0;
}
case WM_RBUTTONDOWN:
{
input::mouseRightDown = true;
return 0;
}
case WM_RBUTTONUP:
{
input::mouseRightDown = false;
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
}
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
// hInstance is bascily the app
// lpcmdline is the command line args
// and the ncmdhsow is hint how to show the window form window SW_SHOW SW_MAIMIZE SW_MINIMIZE
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, int nCmdShow) {
// just make copnsole work
AllocConsole();
freopen("CONOUT$", "w", stdout);
HWND hwnd = Window::SetUpWindow(hInstance, WindowProc, nCmdShow);
Engine::Run();
return 0;
}