//-------------------------------------------------------------------------------------- // Initialize everything and go into a render loop //-------------------------------------------------------------------------------------- int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { HRESULT hr; V_RETURN(DXUTSetMediaSearchPath(MEDIA_PATH)); // Enable run-time memory check for debug builds. #if defined(DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif // Set general DXUT callbacks DXUTSetCallbackFrameMove(OnFrameMove); DXUTSetCallbackKeyboard(OnKeyboard); DXUTSetCallbackMouse(OnMouse); DXUTSetCallbackMsgProc(MsgProc); DXUTSetCallbackDeviceChanging(ModifyDeviceSettings); DXUTSetCallbackDeviceRemoved(OnDeviceRemoved); // Set the D3D11 DXUT callbacks DXUTSetCallbackD3D11DeviceAcceptable (IsD3D11DeviceAcceptable); DXUTSetCallbackD3D11DeviceCreated (OnD3D11CreateDevice); DXUTSetCallbackD3D11SwapChainResized (OnD3D11ResizedSwapChain); DXUTSetCallbackD3D11FrameRender (OnD3D11FrameRender); DXUTSetCallbackD3D11SwapChainReleasing(OnD3D11ReleasingSwapChain); DXUTSetCallbackD3D11DeviceDestroyed (OnD3D11DestroyDevice); // Perform any application-level initialization here InitAOParams(g_AOParams); InitGUI(); UINT Width = 1920; UINT Height = 1200; DXUTInit(true, true, NULL); // Parse the command line, show msgboxes on error, no extra command line params DXUTSetCursorSettings(true, true); // Show the cursor and clip it when in full screen DXUTSetIsInGammaCorrectMode(false); // Do not use a SRGB back buffer for this sample DXUTCreateWindow(L"Deinterleaved Texturing"); DXUTCreateDevice(D3D_FEATURE_LEVEL_11_0, true, Width, Height); //DXUTToggleFullScreen(); DXUTMainLoop(); // Enter into the DXUT render loop // Perform any application-level cleanup here return DXUTGetExitCode(); }
//-------------------------------------------------------------------------------------- // Entry point to the program. Initializes everything and goes into a message processing // loop. Idle time is used to render the scene. //-------------------------------------------------------------------------------------- int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // DXUT will create and use the best device (either D3D9 or D3D10) // that is available on the system depending on which D3D callbacks are set below //------------------------------------------------------------------------- //Initialize test command window //------------------------------------------------------------------------- RedirectIOToConsole(L"output window"); // DXUT will create and use the best device (either D3D9 or D3D10) // that is available on the system depending on which D3D callbacks are set below // Set DXUT callbacks DXUTSetCallbackDeviceChanging( ModifyDeviceSettings ); DXUTSetCallbackMsgProc( MsgProc ); DXUTSetCallbackKeyboard( OnKeyboard ); DXUTSetCallbackFrameMove( OnFrameMove ); DXUTSetCallbackD3D10DeviceAcceptable( IsD3D10DeviceAcceptable ); DXUTSetCallbackD3D10DeviceCreated( OnD3D10CreateDevice ); DXUTSetCallbackD3D10SwapChainResized( OnD3D10SwapChainResized ); DXUTSetCallbackD3D10FrameRender( OnD3D10FrameRender ); DXUTSetCallbackD3D10SwapChainReleasing( OnD3D10SwapChainReleasing ); DXUTSetCallbackD3D10DeviceDestroyed( OnD3D10DestroyDevice ); HRESULT hr; V_RETURN(DXUTSetMediaSearchPath(L"..\\Source\\SoftShadows")); InitApp(); DXUTInit( true, true, NULL ); // Parse the command line, show msgboxes on error, no extra command line params DXUTSetCursorSettings( true, true ); // Show the cursor and clip it when in full screen DXUTCreateWindow( L"SoftShadows" ); DXUTCreateDevice( true, 1024, 768 ); DXUTMainLoop(); // Enter into the DXUT render loop return DXUTGetExitCode(); }
//-------------------------------------------------------------------------------------- // Create any D3D10 resources that aren't dependant on the back buffer //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D10CreateDevice(ID3D10Device* pDev10, const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc, void* pUserContext) { HRESULT hr; g_pSkyBox = new S3UTSkybox(); //g_pEnvMap = new HDRCubeTexture; V_RETURN(DXUTSetMediaSearchPath(L"..\\Source\\SoftShadows")); V_RETURN(g_DialogResourceManager.OnD3D10CreateDevice(pDev10)); V_RETURN(g_D3DSettingsDlg.OnD3D10CreateDevice(pDev10)); V_RETURN(D3DX10CreateFont(pDev10, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_pFont10)); g_SampleUI.GetSlider(IDC_LIGHT_SIZE)->SetValue((int)(g_fFilterSize * 200.0)); g_SampleUI.GetComboBox(IDC_SHADOW_ALGORITHM)->SetSelectedByIndex(ssmap.bAccurateShadow == true ? 0 : 1); switch( ShadowAlgorithm ) { case STANDARD_BP: g_ABP.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; case BP_MSSM_KERNEL: g_BPMSSMKernel.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; case STD_VSM: g_StdVSM.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; case MIP_VSM: g_MipVSM.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; case HIR_BP: g_HBP.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; case BP_GI: g_BPGI.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; case STD_PCSS: g_PCSS.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); break; default: break; } g_NoShadow.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); g_Final.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); g_GBuffer.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); g_ScrQuadRender.OnD3D10CreateDevice(g_ABP.m_pEffect,pDev10,pBackBufferSurfaceDesc,pUserContext); ssmap.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext); g_Widget.OnD3D10CreateDevice( pDev10,pBackBufferSurfaceDesc,pUserContext ); g_Blender.OnD3D10CreateDevice( pDev10,pBackBufferSurfaceDesc,pUserContext ); V_RETURN(D3DX10CreateSprite(pDev10, 512, &g_pSprite10)); {//must be after g_ABP create a device,because they uses the members of g_ABP static const D3D10_INPUT_ELEMENT_DESC scenemeshlayout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0 }, }; if (g_MeshLight.Create(pDev10, L"arrow.x", (D3D10_INPUT_ELEMENT_DESC*)scenemeshlayout, 3) != S_OK) { MessageBox(DXUTGetHWND(), L"Could not load geometry from arrow.x", L"Error", MB_OK); exit(0); } D3D10_PASS_DESC PassDesc; V_RETURN(g_NoShadow.m_pEffect->GetTechniqueByName("RenderAcc")->GetPassByIndex(0)->GetDesc(&PassDesc)); V_RETURN(pDev10->CreateInputLayout(scenemeshlayout, 3, PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize, &g_pMaxLayout)); } LoadNewModel(); //V_RETURN( DXUTFindDXSDKMediaFileCch( g_EnvMapFilePath, MAX_PATH_STR, g_DefaultEnvMapName[0] ) ); //g_pEnvMap->OnCreateDevice(pDev10, g_EnvMapFilePath, DXGI_FORMAT_R8G8B8A8_UNORM); g_pSkyBox->OnCreateDevice( pDev10 ); // g_pSkyBox->SetTexture( g_pEnvMap->m_TextureRV ); g_pFloatBufferSurfaceDesc.SampleDesc.Count = pBackBufferSurfaceDesc->SampleDesc.Count; g_pFloatBufferSurfaceDesc.SampleDesc.Quality = pBackBufferSurfaceDesc->SampleDesc.Quality; D3DXVECTOR3 vTmp = D3DXVECTOR3(1, 2, 3); D3DXVec3Normalize(&g_vLightDir, &vTmp); SAFE_RELEASE(g_pRenderState); D3D10_RASTERIZER_DESC RasterizerState; RasterizerState.FillMode = D3D10_FILL_SOLID; RasterizerState.CullMode = D3D10_CULL_FRONT; RasterizerState.FrontCounterClockwise = true; RasterizerState.DepthBias = false; RasterizerState.DepthBiasClamp = 0.1; RasterizerState.SlopeScaledDepthBias = 0; RasterizerState.DepthClipEnable = true; RasterizerState.ScissorEnable = false; RasterizerState.MultisampleEnable = false; RasterizerState.AntialiasedLineEnable = false; V(pDev10->CreateRasterizerState(&RasterizerState, &g_pRenderState)); SAFE_RELEASE(g_pDSState); D3D10_DEPTH_STENCIL_DESC DSState; ZeroMemory(&DSState, sizeof(DSState)); DSState.DepthEnable = true; DSState.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL; DSState.DepthFunc = D3D10_COMPARISON_LESS_EQUAL; V(pDev10->CreateDepthStencilState(&DSState, &g_pDSState)); //light management for( int light_idx = 0; light_idx < NUM_LIGHT; ++light_idx ) { g_pLightLumiBuffer[light_idx] = new RenderObject( "RenderScreenPixelPos" ); g_pLightLumiBuffer[light_idx] ->OnD3D10CreateDevice( NULL,pDev10, pBackBufferSurfaceDesc, pUserContext); } g_pBlendBuffer = new RenderObject( "RenderScreenPixelPos" ); g_pBlendBuffer->OnD3D10CreateDevice( NULL,pDev10, pBackBufferSurfaceDesc, pUserContext); g_pWidgetBuffer = new RenderObject( "RenderScreenPixelPos" );//fake tech name,we dont want to use it. We only want to utilize its buffers g_pWidgetBuffer->OnD3D10CreateDevice( NULL,pDev10, pBackBufferSurfaceDesc, pUserContext); //-------------------------------------------------------------------------------------------------------- return S_OK; }