int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
					LPSTR lpszArgument, int nFunsterStil)
					//int _tmain(int argc, TCHAR *argv[]) 
{ 
	try{
		MyRegisterClass(hThisInstance);

		Gdiplus::GdiplusStartupInput gdiSI;
		Gdiplus::GdiplusStartupOutput gdiSO;
		ULONG_PTR gdiToken;
		ULONG_PTR gdiHookToken;
		gdiSI.SuppressBackgroundThread = TRUE;
		Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO);
		gdiSO.NotificationHook(&gdiHookToken);


		CSplashWnd splash;

		Gdiplus::Bitmap* pImage;

		if (_access("splash.png", 0)==-1)
		{			
			CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource;
			if (pBitmap->Load(SPLASH_GIF))
			{
				pImage = pBitmap->m_pBitmap;
			}
		}else{
			pImage = Gdiplus::Bitmap::FromFile(L"splash.png");
		}

		splash.SetImage(pImage);
		splash.SetWindowName(L"Marktfuehrer wird geladen...");

		delete pImage; // you are free to delete now
		



		if (checkIfProcessIsAlreadyRunning())
		{
			::MessageBox(NULL, L"Die Anwendung wurde bereits geladen...", L"Info", MB_ICONINFORMATION);
			exit(0);
		}else
		{
			splash.Show();
			CreateChildProcess();

			BOOL loaded = FALSE;
			UINT progressTotal = 0;
			UINT oldProgress = -1;

			// Main message loop:
			while (GetMessage(&msg, NULL, 0, 0))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}

			gdiSO.NotificationUnhook(gdiHookToken);
			Gdiplus::GdiplusShutdown(gdiToken);

			exit(0);
			return (int) msg.wParam;
		}
	}
	catch(exception& e){
		::MessageBox(NULL, L"Die Anwendung konnte die Ladeanzeige nicht finden. Der Marktführer wurde dennoch gestartet. Das kann einen Momemt dauern. Dabei wir Ihnen kein Ladebildschirm gezeigt.", L"Failed", MB_ICONSTOP);
		exit(0);
		return (int) msg.wParam;
	}

} 
Exemple #2
0
bool Projekt::Init()
{
	CSplashWnd splash;
	splash.SetImage(Gdiplus::Image::FromFile(L"Data\\Textures\\test.jpg"));
	splash.Show();
	splash.SetProgressBarColor(0x00000000);
	splash.SetAutoProgress(0, 100, 50);

	if (!D3D11App::Init())
		return false;

	// Read game settings
	if (!Settings::GetInstance()->ReadFile("Data\\Settings.txt"))
		return false;

	// Initialize effects, input layouts and texture manager
	Effects::InitAll(mDirect3D->GetDevice());
	InputLayouts::InitAll(mDirect3D->GetDevice());
	mTextureMgr.Init(mDirect3D->GetDevice());
	RenderStates::InitAll(mDirect3D->GetDevice());

	// Initialize models
	GenericHandler::GetInstance()->Initialize(mDirect3D->GetDevice(), &mTextureMgr);
	Python->Initialize();


	//Create and initialize the GUI
	Gui->Init(mDirect3D->GetDevice());

	Network::GetInstance()->Initialize();
	Network::GetInstance()->Start();

	//init soundmodule
	this->soundModule = new SoundModule();
	this->soundModule->initialize(this->mhMainWnd, this->mDirectInput);

	
	// Create game
	mGame = new Game(mDirect3D->GetDevice(), mDirect3D->GetImmediateContext(), &mTextureMgr, soundModule);

	// Set if window is fullscreen or not
	D3D11App::SetFullscreen(Settings::GetInstance()->GetData().IsFullscreen);

	// Resize window after we've created our Game object
	D3D11App::SetResolution(Settings::GetInstance()->GetData().Width,
		Settings::GetInstance()->GetData().Height);

	// Create sky
	mSky = new Sky(mDirect3D->GetDevice(), L"Data\\Textures\\SkyBox_Space.dds", 5000.0f);

	// Create shadow map
	mShadowMap = new ShadowMap(mDirect3D->GetDevice(), 2048, 2048);

	// Create frustum culling
	mFrustumCulling = new FrustumCulling();

	//--------------------------------------------------------
	// Compute scene bounding box
	//--------------------------------------------------------
// 	XMFLOAT3 minPt(+MathHelper::infinity, +MathHelper::infinity, +MathHelper::infinity);
// 	XMFLOAT3 maxPt(-MathHelper::infinity, -MathHelper::infinity, -MathHelper::infinity);
// 
// 	// Get vertex positions from all models
// 	for (UINT i = 0; i < mGenericInstances.size(); ++i)
// 	{
// 		for (UINT j = 0; j < mGenericInstances[i].model->vertices.size(); ++j)
// 		{
// 			XMFLOAT3 vPos = mGenericInstances[i].model->vertices[j]->position;
// 
// 			minPt.x = MathHelper::getMin(minPt.x, vPos.x);
// 			minPt.y = MathHelper::getMin(minPt.x, vPos.x);
// 			minPt.z = MathHelper::getMin(minPt.x, vPos.x);
// 
// 			maxPt.x = MathHelper::getMax(maxPt.x, vPos.x);
// 			maxPt.y = MathHelper::getMax(maxPt.x, vPos.x);
// 			maxPt.z = MathHelper::getMax(maxPt.x, vPos.x);
// 		}
// 	}
// 
// 	// Sphere center is at half of these new dimensions
// 	mSceneBounds.Center = XMFLOAT3(	0.5f*(minPt.x + maxPt.x),
// 		0.5f*(minPt.y + maxPt.y),
// 		0.5f*(minPt.z + maxPt.z));
// 
// 	// Calculate the sphere radius
// 	XMFLOAT3 extent(0.5f*(maxPt.x - minPt.x),
// 		0.5f*(maxPt.y - minPt.y),
// 		0.5f*(maxPt.z - minPt.z));
// 
// 	mSceneBounds.Radius = sqrtf(extent.x*extent.x + extent.y*extent.y + extent.z*extent.z);
	splash.Hide();
	D3D11App::ShowWindow();
	OnResize();

	return true;
}