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
|
#ifndef __WINMAIN_H
#define __WINMAIN_H
#include "WinMain.h"
#include "Engine.h"
using namespace DarkMatter;
DarkMatter::Engine engine;
LRESULT CALLBACK WinProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
{
gameover = true;
PostQuitMessage(0);
}
}
return DefWindowProc(window, message, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow)
{
g_instance = instance;
g_CmdLine = lpCmdLine;
g_CmdShow = nCmdShow;
WNDCLASSEX wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.cbSize = sizeof(WNDCLASSEX);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = NULL;
wc.hIconSm = NULL;
wc.hInstance = instance;
wc.lpfnWndProc = (WNDPROC)WinProc;
wc.lpszClassName = Title.c_str();
wc.lpszMenuName = NULL;
wc.style = CS_VREDRAW | CS_HREDRAW;
RegisterClassEx(&wc);
g_window = CreateWindowEx(
0,
Title.c_str(),
Title.c_str(),
WS_OVERLAPPEDWINDOW,
0, 0,
SCREENW, SCREENH,
NULL,
NULL,
g_instance,
NULL);
ShowWindow(g_window, g_CmdShow);
UpdateWindow(g_window);
MSG message;
engine.SetWindow(g_window);
engine.e_Init();
engine.Message(engine.GetVersion(), "DM Version");
while (!gameover)
{
if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
engine.Render();
}
return message.wParam;
}
#endif __WINMAIN_H
|