//-------------------------------------------------------
// DEFINES
//-------------------------------------------------------
#define WINDOW_CLASS_NAME "Game Shell Window"
//--------------------------------------------------------
// INCLUDES
//--------------------------------------------------------
#include "GameShell.h"
//--------------------------------------------------------
// GLOBALS
//--------------------------------------------------------
HWND main_window_handle = NULL;
HINSTANCE hinstance_app = NULL;
//--------------------------------------------------------
// Funktionsdefinitionen
//--------------------------------------------------------
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT msg,
WPARAM wparam,
LPARAM lparam)
{
PAINTSTRUCT ps;
HDC hdc;
// Nachrichtenverarbeitung
switch(msg)
{
case WM_CREATE:
{
return(0);
}
break;
case WM_PAINT:
{
hdc = BeginPaint(hwnd, &ps);
EndPaint(hwnd, &ps);
return(0);
}
break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
}
break;
default:
break;
}
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
///////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int ncmdshow)
{
WNDCLASSEX winclass;
HWND hwnd;
MSG msg;
// Fenstereigenschaften festlegen
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
hinstance_app = hinstance;
if(!RegisterClassEx(&winclass))
return(0);
InitResolution();
if(!(hwnd = CreateWindowEx(NULL,
WINDOW_CLASS_NAME,
"My Game Shell",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
screenwidth, screenheight,
NULL,
NULL,
hinstance,
NULL)))
return(0);
main_window_handle = hwnd;
Game_Init();
while(TRUE) // Nachrichtenweiterleitung
{
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if(msg.message==WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Game_Main();
}
Game_Shutdown();
}
////////////////////////////////////////////////////////////////////
void Game_Init()
{
GameInitialisierungsRoutine();
}
////////////////////////////////////////////////////////////////////
void Game_Main()
{
// Mit ESC kann die Anwendung verlassen werden
if(KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle, WM_CLOSE, 0, 0);
GameMainRoutine();
}
/////////////////////////////////////////////////////////////////////
void Game_Shutdown()
{
GameCleanUpRoutine();
}