Пример #1
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_CREATE:
		WindowInit(hWnd, wParam, lParam);
		break;
	case WM_PAINT:
		Render(hWnd);
		break;
	case WM_KEYDOWN:
		KeyDown(hWnd, wParam, lParam);
		break;
	case WM_KEYUP:
		break;
	case WM_MOUSEMOVE:
		MouseMove(hWnd, wParam, lParam);
		break;
	case WM_LBUTTONDOWN:
		LButtonDown(hWnd, wParam, lParam);
		break;
	case WM_TOUCH:
		return TouchEvent(hWnd, message, wParam, lParam);
	case WM_TIMER:
		TimerUpdate(hWnd, wParam, lParam);
		break;
	case WM_DESTROY:
		RemoveFontResource(_T("res/font/fantiquefour.ttf"));
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	return 0;
}
Пример #2
0
// Program Entry (WinMain)
//int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
int main()
{
	HINSTANCE hInstance = NULL;
	application_t	*app; // = ApplicationNew("OpenGL", hInstance);
	application_t	*app2; // = ApplicationNew("OpenGL 2", hInstance);
	gl_window_t	*win1, *win2;
	
	app = ApplicationNew("OpenGL", hInstance);
	app2 = ApplicationNew("OpenGL 2", hInstance);
start:
	
	// left, top, width, height
	char title[1024];
	sprintf(title, "system metrics: %dx%d", GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));

	win1 = WindowNew(app, title, 100, 100, 1024, 768, MyInitialize, MyDeinitialize, MyUpdate, MyDraw);
	if ( ! win1->isCreated) {
		MessageBox (HWND_DESKTOP, "Error Creating OpenGL Window", "Error", MB_OK | MB_ICONEXCLAMATION);
		return -1;
	}

	win2 = WindowNew(app2, title, 100, 100, 1024, 768, MyInitialize, MyDeinitialize, MyUpdate, MyDraw);
	if ( ! win2->isCreated) {
		MessageBox (HWND_DESKTOP, "Error Creating OpenGL Window", "Error", MB_OK | MB_ICONEXCLAMATION);
		return -1;
	}

	// Ask The User If They Want To Start In FullScreen Mode? (Remove These 4 Lines If You Want To Force Fullscreen)
	//if (MessageBox (HWND_DESKTOP, "Would You Like To Run In Fullscreen Mode?", "Start FullScreen?", MB_YESNO | MB_ICONQUESTION) == IDNO)
	//{
	//	window.init.isFullScreen = FALSE;								// If Not, Run In Windowed Mode
	//}
	
	
	WindowInit(win1);
	WindowInit(win2);
	int quitcounter = 0;
	while (1) {
		if (! win1->quit) {
			WindowUpdate(win1);
			WindowDraw(win1);
			WindowMessageLoop(win1);
		}
		
		if (! win2->quit) {
			WindowUpdate(win2);
			WindowDraw(win2);
			WindowMessageLoop(win2);
		}

		if (win1->quit && win2->quit)
			break;
	}
	
	goto start;
	
	ApplicationClose(app);
	ApplicationClose(app2);

	
	return 0;
}
Пример #3
0
void WINAPI	EntryPoint()	
#endif
{

#ifdef ALLOW_WINDOWED
//	gs_WindowInfos.bFullscreen = MessageBox( 0, "Fullscreen?", pWindowClass, MB_YESNO | MB_ICONQUESTION ) == IDYES;
	gs_WindowInfos.bFullscreen = false;
#endif

	int	ErrorCode = 0;
	if ( (ErrorCode = WindowInit()) )
	{
		WindowExit();
		MessageBox( 0, pMessageError, 0, MB_OK | MB_ICONEXCLAMATION );
		ExitProcess( ErrorCode );
	}

	IntroProgressDelegate	Progress = { &gs_WindowInfos, ShowProgress };
	if ( (ErrorCode = IntroInit( Progress )) )
	{
		WindowExit();
		MessageBox( 0, pMessageError, 0, MB_OK | MB_ICONEXCLAMATION );
		ExitProcess( -ErrorCode );
	}

	// Start the music
#ifdef MUSIC
	gs_Music.Play();
#endif

	//////////////////////////////////////////////////////////////////////////
	// Run the message loop !
	bool	bFinished = false;
    float	StartTime = 0.001f * timeGetTime(); 
	float	LastTime = 0.0f;

	while ( !bFinished )
	{
		float	Time = 0.001f * timeGetTime() - StartTime;
	    float	DeltaTime = Time - LastTime;
		LastTime = Time;

		// Process Windows messages
		MSG		msg;
		while ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) )
		{
			if ( msg.message == WM_QUIT )
			{
				bFinished = true;
				break;
			}
			DispatchMessage( &msg );
		}

#ifndef NDEBUG
		// Show FPS
		DrawTime( Time );
		HandleEvents();
#endif

#ifdef SURE_DEBUG
		// Check for hash collisions => We must never have too many of them !
		ASSERT( DictionaryU32::ms_MaxCollisionsCount < 2, "Too many collisions in hash tables! Either increase size or use different hashing scheme!" );

		// Reload in-file constants
		ReloadChangedTweakableValues();

		// Reload modified shaders
		WatchIncludesModifications();
		Shader::WatchShadersModifications();
		ComputeShader::WatchShadersModifications();
#endif

		// Run the intro
		bFinished |= !IntroDo( Time, DeltaTime );

// This was in iQ's framework, I don't know what it's for. I believe it's useful when using OpenGL but with DirectX it makes everything slow as hell (attempts to load/unload DLLs every frame) !
// I left it here so everyone knows it must NOT be called...
//		SwapBuffers( gs_WindowInfos.hDC );
	}
	//
	//////////////////////////////////////////////////////////////////////////

	// Stop the music
#ifdef MUSIC
	gs_Music.Stop();
#endif

 	IntroExit();

	WindowExit();

	// Clean exit...
	ExitProcess( 0 );
}