//-------------------------------------------------------------------------------------- // SwapChain has changed and may have new attributes such as size. // Create any D3D11 resources that depend on the back buffer //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D11ResizedSwapChain(ID3D11Device* pd3dDevice, IDXGISwapChain *pSwapChain, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext) { HRESULT hr; DXUTTRACE(L"OnD3D11ResizedSwapChain called\n"); V_RETURN( g_DialogResourceManager.OnD3D11ResizedSwapChain(pd3dDevice, pBackBufferSurfaceDesc) ); V_RETURN( g_SettingsDlg.OnD3D11ResizedSwapChain(pd3dDevice, pBackBufferSurfaceDesc) ); g_BackBufferWidth = pBackBufferSurfaceDesc->Width; g_BackBufferHeight = pBackBufferSurfaceDesc->Height; g_FullViewport.TopLeftX = 0.f; g_FullViewport.TopLeftY = 0.f; g_FullViewport.MinDepth = 0.f; g_FullViewport.MaxDepth = 1.f; g_FullViewport.Width = (FLOAT)g_BackBufferWidth; g_FullViewport.Height = (FLOAT)g_BackBufferHeight; // Setup the camera's projection parameters float AspectRatio = (float)g_BackBufferWidth / (float)g_BackBufferHeight; g_OrbitalCamera.SetProjParams (FOVY, AspectRatio, ZNEAR, ZFAR); g_OrbitalCamera.SetWindow (g_BackBufferWidth, g_BackBufferHeight); g_OrbitalCamera.SetButtonMasks(MOUSE_LEFT_BUTTON, MOUSE_WHEEL, 0); g_FirstPersonCamera.SetProjParams (FOVY, AspectRatio, ZNEAR, ZFAR); g_FirstPersonCamera.SetRotateButtons( 1, 1, 1 ); UINT HudWidth = 256; float HudOpacity = 0.32f; g_HUD.SetLocation(g_BackBufferWidth - HudWidth, 0); g_HUD.SetSize (HudWidth, g_BackBufferHeight); g_HUD.SetBackgroundColors(D3DCOLOR_COLORVALUE(0,0,0,HudOpacity)); // Allocate our own screen-sized buffers, as the SwapChain only contains a non-MSAA color buffer. ResizeScreenSizedBuffers(pd3dDevice); return hr; }
void InitApp() { g_HUD.Init(&g_DialogResourceManager); g_SampleUI.Init(&g_DialogResourceManager); g_WhiteArrowDialog.Init(&g_DialogResourceManager); g_BlackArrowDialog.Init(&g_DialogResourceManager); g_TheWhiteWinnerDialog.Init(&g_DialogResourceManager); g_TheBlackWinnerDialog.Init(&g_DialogResourceManager); g_HUD.SetCallback(OnGUIEvent); int iY = 10; g_HUD.AddButton(IDC_TOGGLEFULLSCREEN, L"Toggle Full Screen", 35, iY, 125, 22); g_HUD.AddButton(IDC_HIDECONSOLE, L"Console", 35, iY += 24, 125, 22); g_HUD.AddButton(IDC_LAUNCH_RENJU_MANUAL, L"Manual", 35, iY += 24, 125, 22); g_HUD.AddButton(IDC_RESETGAME, L"Start", 35, iY += 24, 125, 22); g_SampleUI.AddRadioButton(IDC_GAMEMODE_HUMAN_HUMAN_RADIO, 1, L"Human - Human", 35, iY += 24, 220, 24, true, L'1'); g_SampleUI.AddRadioButton(IDC_GAMEMODE_AI_IS_BLACK_RADIO, 1, L"AI is Black", 35, iY += 24, 220, 24, false, L'2'); g_SampleUI.AddRadioButton(IDC_GAMEMODE_AI_IS_WHITE_RADIO, 1, L"AI is White", 35, iY += 24, 220, 24, false, L'3'); g_SampleUI.SetCallback(OnGUIEvent); CDXUTStatic* pStatic = NULL; CDXUTElement* pElement = g_WhiteArrowDialog.GetDefaultElement(DXUT_CONTROL_STATIC, 0); if(pElement) { pElement->FontColor.Init(D3DCOLOR_ARGB(255, 255, 255, 255)); } g_WhiteArrowDialog.SetSize(150, 100); g_WhiteArrowDialog.SetBackgroundColors(D3DCOLOR_ARGB(0, 255, 255, 255), D3DCOLOR_ARGB(0, 255, 255, 255), D3DCOLOR_ARGB(0, 255, 255, 255), D3DCOLOR_ARGB(0, 255, 255, 255)); g_WhiteArrowDialog.SetCallback(OnGUIEvent); g_WhiteArrowDialog.SetFont(0, L"Arial", 120, FW_BOLD); g_WhiteArrowDialog.AddStatic(IDC_WHITESCORE, L"2", 0, 0, g_WhiteArrowDialog.GetWidth(), g_WhiteArrowDialog.GetHeight(), false, &pStatic); pElement = g_BlackArrowDialog.GetDefaultElement(DXUT_CONTROL_STATIC, 0); if(pElement) { pElement->FontColor.Init(D3DCOLOR_ARGB(255, 0, 0, 0)); } g_BlackArrowDialog.SetSize(150, 100); g_BlackArrowDialog.SetBackgroundColors(D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16)); g_BlackArrowDialog.SetCallback(OnGUIEvent); g_BlackArrowDialog.SetFont(0, L"Arial", 120, FW_BOLD); g_BlackArrowDialog.AddStatic(IDC_BLACKSCORE, L"2", 0, 0, g_BlackArrowDialog.GetWidth(), g_BlackArrowDialog.GetHeight(), false, &pStatic); pElement = g_TheWhiteWinnerDialog.GetDefaultElement(DXUT_CONTROL_STATIC, 0); if(pElement) { pElement->FontColor.Init(D3DCOLOR_ARGB(255, 255, 255, 255)); } pElement = g_TheWhiteWinnerDialog.GetDefaultElement(DXUT_CONTROL_STATIC, 0); g_TheWhiteWinnerDialog.SetSize(500, 100); g_TheWhiteWinnerDialog.SetBackgroundColors(D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16)); g_TheWhiteWinnerDialog.SetCallback(OnGUIEvent); g_TheWhiteWinnerDialog.SetFont(0, L"Arial", 60, FW_BOLD); g_TheWhiteWinnerDialog.AddStatic(IDC_THE_WHITE_WINNER_DIALOG, L"2", 0, 0, g_TheWhiteWinnerDialog.GetWidth(), g_TheWhiteWinnerDialog.GetHeight(), false, &pStatic); pElement = g_TheBlackWinnerDialog.GetDefaultElement(DXUT_CONTROL_STATIC, 0); if(pElement) { pElement->FontColor.Init(D3DCOLOR_ARGB(255, 0, 0, 0)); } pElement = g_TheBlackWinnerDialog.GetDefaultElement(DXUT_CONTROL_STATIC, 0); g_TheBlackWinnerDialog.SetSize(500, 100); g_TheBlackWinnerDialog.SetBackgroundColors(D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16), D3DCOLOR_ARGB(0, 16, 16, 16)); g_TheBlackWinnerDialog.SetCallback(OnGUIEvent); g_TheBlackWinnerDialog.SetFont(0, L"Arial", 60, FW_BOLD); g_TheBlackWinnerDialog.AddStatic(IDC_THE_BLACK_WINNER_DIALOG, L"2", 0, 0, g_TheBlackWinnerDialog.GetWidth(), g_TheBlackWinnerDialog.GetHeight(), false, &pStatic); }