Example #1
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

 	// TODO: Place code here.
	MSG msg;
	ZERO_OUT(msg);

	HACCEL hAccelTable;

	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_SCENEVIEWER, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);

	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}

	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_SCENEVIEWER));






	SetupBaseUtil	setupBase;

	FileLogUtil		fileLog;
	SetupCoreUtil	setupCore;

	SetupEngineUtil	setupEngine;


	CConsole	console(APP_TITLE);
	console.setTopLeft(0,0);




	MyApp			app;

#if 0
	vector2d<int>	resolution(800,600);
	vector2d<int>	topLeftCorner(800,450);
#else
	//vector2d<int>	resolution(1024,768);
	vector2d<int>	resolution(1400,900);
	vector2d<int>	topLeftCorner(0,0);
#endif



	GetMessage(&msg, NULL, 0, 0);


	{
		MyAppWindow		appWindow( &app, msg.hwnd );
		appWindow.bringToFront();
		appWindow.setTopLeft( topLeftCorner.x, topLeftCorner.y );

		g_pMainWindow = &appWindow;



		app.PreInit_CreateViewports( &appWindow );



		GameTimer		timer;


UNDONE;
		if( !app.Initialize(MXC("???")) ) {
			return -1;
		}


		// Main message loop:
		while( true )
		{
			BOOL	bPendingMsg = FALSE;

			//if( appWindow.isActive() )
			{
				bPendingMsg = ::PeekMessage( &msg, NULL, 0, 0, PM_REMOVE );
			}
			//else
			//{
			//	bPendingMsg = ::GetMessage( &msg, NULL, 0, 0 );
			//}

			if( msg.message == WM_QUIT )
			{
				break;
			}


			//if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
			//{
			//	TranslateMessage(&msg);
			//	DispatchMessage(&msg);
			//}

			if( bPendingMsg )
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}


			const F4 deltaSeconds = timer.TickFrame();

			appWindow.Tick( deltaSeconds );

			appWindow.Draw();

			MX_PROFILE_INCREMENT_FRAME_COUNTER;

			mxSleepMilliseconds(1);
		}


		app.Shutdown();
	}




	return (int) msg.wParam;
}