//-------------------------------------------------------------------------------------- _Use_decl_annotations_ DXUTAPI bool CDXUTIMEEditBox::StaticMsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(hWnd); UNREFERENCED_PARAMETER(wParam); if (!ImeUi_IsEnabled()) return false; #if defined(DEBUG) || defined(_DEBUG) m_bIMEStaticMsgProcCalled = true; #endif switch (uMsg) { case WM_INPUTLANGCHANGE: DXUTTRACE(L"WM_INPUTLANGCHANGE\n"); { } return true; case WM_IME_SETCONTEXT: DXUTTRACE(L"WM_IME_SETCONTEXT\n"); // // We don't want anything to display, so we have to clear this // lParam = 0; return false; // Handle WM_IME_STARTCOMPOSITION here since // we do not want the default IME handler to see // this when our fullscreen app is running. case WM_IME_STARTCOMPOSITION: DXUTTRACE(L"WM_IME_STARTCOMPOSITION\n"); ResetCompositionString(); // Since the composition string has its own caret, we don't render // the edit control's own caret to avoid double carets on screen. s_bHideCaret = true; return true; case WM_IME_ENDCOMPOSITION: DXUTTRACE(L"WM_IME_ENDCOMPOSITION\n"); s_bHideCaret = false; return false; case WM_IME_COMPOSITION: DXUTTRACE(L"WM_IME_COMPOSITION\n"); return false; } return false; }
//-------------------------------------------------------------------------------------- // This callback function will be called immediately after the Direct3D device has // been destroyed, which generally happens as a result of application termination or // windowed/full screen toggles. //-------------------------------------------------------------------------------------- void CALLBACK OnD3D11DestroyDevice(void* pUserContext) { DXUTTRACE(L"OnD3D11DestroyDevice called\n"); g_DialogResourceManager.OnD3D11DestroyDevice(); g_SettingsDlg.OnD3D11DestroyDevice(); DXUTGetGlobalResourceCache().OnDestroyDevice(); SAFE_DELETE(g_pTxtHelper); g_pSceneRenderer.OnDestroyDevice(); for (int i = 0; i < ARRAYSIZE(g_MeshDesc); i++) { g_SceneMeshes[i].OnDestroyDevice(); } ReleaseRenderTargets(); ReleaseDepthBuffer(); g_AORenderer.Release(); }
//-------------------------------------------------------------------------------------- // 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; }
//-------------------------------------------------------------------------------------- // Create any D3D11 resources that aren't dependant on the back buffer //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext) { HRESULT hr; DXUTTRACE(L"OnD3D11CreateDevice called\n"); SetCursor(LoadCursor(0, IDC_ARROW)); ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext(); // does not addref V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext) ); V_RETURN( g_SettingsDlg.OnD3D11CreateDevice(pd3dDevice) ); g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, g_TextLineHeight); // Setup orbital camera D3DXVECTOR3 vecEye(0.0f, 2.0f, 0.0f); D3DXVECTOR3 vecAt (0.0f, 0.0f, 0.0f); g_OrbitalCamera.SetViewParams(&vecEye, &vecAt); g_OrbitalCamera.SetRadius(1.5f, 0.01f); // Setup first-person camera D3DXVECTOR3 sibenikVecEye(0.0960150138f, 0.0273544509f, -0.0185411610f); D3DXVECTOR3 sibenikVecAt (-0.623801112f, -0.649074197f, -0.174454257f); g_FirstPersonCamera.SetViewParams(&sibenikVecEye, &sibenikVecAt); g_FirstPersonCamera.SetEnablePositionMovement(1); g_FirstPersonCamera.SetScalers(0.001f, 0.05f); // Load Scene3D.fx g_pSceneRenderer.OnCreateDevice(pd3dDevice); // Load meshes and bin files LoadScenes(pd3dDevice); GFSDK_SSAO_Status status; status = g_AORenderer.Create(pd3dDevice); assert(status == GFSDK_SSAO_OK); return S_OK; }
void CSoundManager::Load( const std::string& file_name ) { std::map< std::string, CSoundWav* >::iterator it = m_buffers.find( file_name ) ; if( it != m_buffers.end() ) return ; HRESULT hr; CSoundWav* p_wav = new CSoundWav() ; // // Locate the wave file // WCHAR strFilePath[MAX_PATH] = {0} ; WCHAR w_path[256] = {0} ; DXconvAnsiToWide( w_path, file_name.c_str(), (file_name.length()+1) ) ; if( FAILED( hr = FindMediaFileCch( strFilePath, MAX_PATH, w_path ) ) ) { #ifdef _DEBUG WCHAR d_buff[256] = {0} ; std::string d_str = "サウンドデータのロードに失敗 001 : " + file_name ; DXconvAnsiToWide( d_buff, d_str.c_str(), (d_str.length()+1) ) ; DXUTTRACE( L"\n------------------------------------------------------------\n" ) ; DXUTTRACE( d_buff ) ; DXUTTRACE( L"\n------------------------------------------------------------\n" ) ; #endif return ; } // // Read in the wave file // if( FAILED( hr = p_wav->m_wav.Open( strFilePath, NULL, WAVEFILE_READ ) ) ) { #ifdef _DEBUG WCHAR d_buff[256] = {0} ; std::string d_str = "サウンドデータのロードに失敗 002 : " + file_name ; DXconvAnsiToWide( d_buff, d_str.c_str(), (d_str.length()+1) ) ; DXUTTRACE( L"\n------------------------------------------------------------\n" ) ; DXUTTRACE( d_buff ) ; DXUTTRACE( L"\n------------------------------------------------------------\n" ) ; #endif return ; } // Get format of wave file WAVEFORMATEX* pwfx = p_wav->m_wav.GetFormat(); // Calculate how many bytes and samples are in the wave DWORD cbWaveSize = p_wav->m_wav.GetSize(); // Read the sample data into memory p_wav->m_p_buffer = new BYTE[ cbWaveSize ]; if( FAILED( hr = p_wav->m_wav.Read( p_wav->m_p_buffer, cbWaveSize, &cbWaveSize ) ) ) { SAFE_DELETE_ARRAY( p_wav->m_p_buffer ); #ifdef _DEBUG WCHAR d_buff[256] = {0} ; std::string d_str = "サウンドデータのロードに失敗 003 : " + file_name ; DXconvAnsiToWide( d_buff, d_str.c_str(), (d_str.length()+1) ) ; DXUTTRACE( L"\n------------------------------------------------------------\n" ) ; DXUTTRACE( d_buff ) ; DXUTTRACE( L"\n------------------------------------------------------------\n" ) ; #endif return ; } m_buffers.insert( std::make_pair( file_name, p_wav ) ) ; }
//-------------------------------------------------------------------------------------- // Release D3D11 resources created in OnD3D11ResizedSwapChain //-------------------------------------------------------------------------------------- void CALLBACK OnD3D11ReleasingSwapChain(void* pUserContext) { DXUTTRACE(L"OnD3D11ReleasingSwapChain called\n"); g_DialogResourceManager.OnD3D11ReleasingSwapChain(); }