Пример #1
0
//----------------------------------------------------------------------------
// WndProc: Intercepts window events before passing them on to the game.
//----------------------------------------------------------------------------
static LONG WINAPI Direct3DWndProc (
    HWND    hWnd,
    UINT    uMsg,
    WPARAM  wParam,
    LPARAM  lParam)
{
	switch (uMsg)
	{
	case WM_DESTROY:
        // If our window was closed, lose our cached handle
		if (hWnd == g_hWnd) {
            g_hWnd = NULL;
        }
		
        // We want to pass this message on to the MainWndProc
        break;
	case WM_SIZE:

        // @pjb: todo: recreate swapchain?
        // @pjb: actually f**k that. disable window sizing.

        break;

    default:
        break;
    }

    return MainWndProc( hWnd, uMsg, wParam, lParam );
}
Пример #2
0
static ALERROR MainLoop(void)
	// MainLoop
	//
	// Manage SDL events.
	{
	SDL_Event	evt;
	DWORD			dwNow;
	DWORD			dwNextFrame;
	DWORD			dwStartTime = SDL_GetTicks();

	while(g_Running)
		{
		dwNextFrame = dwStartTime + FRAME_DELAY;

		// Render the screen.
		g_pTrans->Animate();

		while (SDL_PollEvent(&evt))
			{
			if (MainWndProc(g_pTrans, &evt))
				{
				return NOERROR;
				}
			}

		// Stall for VSYNC.
		dwNow = SDL_GetTicks();
		if (dwNextFrame > dwNow)
			{
			SDL_Delay(dwNextFrame - dwNow);
			dwStartTime = dwNextFrame;
			}
		else
			{
			dwStartTime = dwNow;
			}
		}

	return NOERROR;
	}