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
|
//main.cpp
#include "declarations.h"
#include "Direct3D.h"
#include "Resource.h"
#include "WindowProc.h"
Direct3D D3DClass;
int InitWindow(HINSTANCE hInst, char* WindowName)
{
int x, y;
x = 800;
y = 550;
WindowClass.cbClsExtra = NULL;
WindowClass.cbSize = sizeof(WNDCLASSEX);
WindowClass.cbWndExtra = NULL;
WindowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WindowClass.hCursor = LoadCursor(hInst, IDI_APPLICATION);
WindowClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONWINDOW));
WindowClass.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONWINDOW));
WindowClass.hInstance = hInst;
WindowClass.lpfnWndProc = WindowProc;
WindowClass.lpszClassName = WindowName;
WindowClass.lpszMenuName = NULL;
WindowClass.style = CS_HREDRAW | CS_VREDRAW;
D3DClass.Init(g_hWindow);
RegisterClassEx(&WindowClass);
g_hWindow = CreateWindowEx(NULL, WindowName, WindowName, WS_OVERLAPPEDWINDOW, GetSystemMetrics(SM_CXSCREEN) / 2 - x / 2,
GetSystemMetrics(SM_CYSCREEN) / 2 - y / 2,
x, y, NULL, NULL, hInst, NULL);
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iShowCmd)
{
MSG message;
InitWindow(hInstance, "Erstes Fenster, Uhuhuh!");
ShowWindow(g_hWindow, iShowCmd);
UpdateWindow(g_hWindow);
while(TRUE)
{
while(PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
if(message.message == WM_QUIT)
{
D3DClass.Quit();
UnregisterClass("Direct3D window", hInstance);
return (int)message.wParam;
}
D3DClass.Render();
}
D3DClass.Quit();
UnregisterClass("Direct3D window", hInstance);
return (int)message.wParam;
}
|