//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D9CreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
{
	g_SettingsDlg.Init( &g_DialogResourceManager );
	g_HUD.Init( &g_DialogResourceManager );
	g_SampleUI.Init( &g_DialogResourceManager );

	g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice );
	g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice );


	g_HUD.SetCallback( OnGUIEvent ); 
	int iY = 10;
	g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 35, iY, 125, 22 );
	g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", 35, iY += 24, 125, 22, VK_F3 );
	g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 35, iY += 24, 125, 22, VK_F2 );

	g_SampleUI.SetCallback( OnGUIEvent );

	iY = 10;
	g_SampleUI.AddCheckBox( IDC_DISABLEALBEDO, L"Disable albedo", 35, iY += 24, 160, 22, g_DisableAlbedo );
	g_SampleUI.AddCheckBox( IDC_PAUSEANIMATION, L"Pause animation", 35, iY += 24, 160, 22, g_PauseAnimation );
	g_SampleUI.AddCheckBox( IDC_DISABLESKINING, L"Disable skining", 35, iY += 24, 160, 22, g_DisableSkining );
	g_SampleUI.AddCheckBox( IDC_SHOWNORMALS, L"Show normals", 35, iY += 24, 160, 22, g_ShowNormals );


	CDXUTComboBox* pCombo;
	g_SampleUI.AddComboBox( IDC_TECHNIQUECOMBO, 35, iY += 30, 160, 22, 0, false, &pCombo );
	if( pCombo )
	{
		pCombo->SetDropHeight( 100 );
		pCombo->AddItem( L"Unpacked TBN", ( LPVOID )0x0 );
		pCombo->AddItem( L"Packed TBN", ( LPVOID )0x1 );
		pCombo->AddItem( L"Unpacked Quaternion", ( LPVOID )0x2 );
		pCombo->AddItem( L"Packed Quaternion", ( LPVOID )0x3 );
		pCombo->SetSelectedByIndex(g_TechniqueIndex);
	}

	iY = 10;

	D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Arial", &g_pFont9 );

	d3dAnimation.Create(pd3dDevice);
	d3dMesh.Create(pd3dDevice);
	d3dFloor.Create(pd3dDevice);

	FBXImporter importer;
	const char* fbxFileName = ".\\data\\MilitaryMechanic.fbx";
	importer.Import(fbxFileName, &d3dMesh, &d3dAnimation);

	return S_OK;
}
예제 #2
0
void AMD::InitApp( ShaderCache& r_ShaderCache, HUD& r_HUD, int& iY, const bool i_bAdvancedShaderCacheGUI_VisibleByDefault )
{
#if !AMD_SDK_PREBUILT_RELEASE_EXE
	g_bAdvancedShaderCacheGUI_IsVisible = i_bAdvancedShaderCacheGUI_VisibleByDefault;

	const int i_old_iY = iY;

	g_pHUD = &r_HUD;
	g_pShaderCache = &r_ShaderCache;

	{
		r_HUD.m_GUI.AddButton( GetEnum(AMD_IDC_BUTTON_SHOW_SHADERCACHE_UI),			L"ShaderCache HUD (F9)", AMD::HUD::iElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, VK_F9 );

		iY = 0;
		static const int iSCElementOffset =  AMD::HUD::iElementOffset - 256;

		r_HUD.m_GUI.AddButton( GetEnum(AMD_IDC_BUTTON_RECOMPILESHADERS_CHANGED),	L"Recompile shaders (F5)", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, VK_F5 );

#if AMD_SDK_INTERNAL_BUILD
		if( r_ShaderCache.GenerateISAGPRPressure() )
		{
			r_HUD.m_GUI.AddButton( GetEnum(AMD_IDC_BUTTON_RECREATE_SHADERS),		L"Gen |ISA| shaders (F6)", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, VK_F6 );
		}
#endif

		r_HUD.m_GUI.AddButton( GetEnum(AMD_IDC_BUTTON_RECOMPILESHADERS_GLOBAL),		L"Build ALL shaders (F7)", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, VK_F7 );

		r_HUD.m_GUI.AddCheckBox( GetEnum(AMD_IDC_CHECKBOX_AUTORECOMPILE_SHADERS),	L"Auto Recompile Shaders", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, r_ShaderCache.RecompileTouchedShaders() );
		if( r_ShaderCache.ShaderErrorDisplayType() == ShaderCache::ERROR_DISPLAY_ON_SCREEN )
		{
			r_HUD.m_GUI.AddCheckBox( GetEnum(AMD_IDC_CHECKBOX_SHOW_SHADER_ERRORS),		L"Show Compiler Errors", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, r_ShaderCache.ShowShaderErrors() );
		}

#if AMD_SDK_INTERNAL_BUILD
		if( r_ShaderCache.GenerateISAGPRPressure() )
		{
			r_HUD.m_GUI.AddCheckBox( GetEnum(AMD_IDC_CHECKBOX_SHOW_ISA_GPR_PRESSURE), L"Show ISA GPR Pressure", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, r_ShaderCache.ShowISAGPRPressure() );
			r_HUD.m_GUI.AddStatic( GetEnum(AMD_IDC_STATIC_TARGET_ISA), L"Target ISA:", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight );

			CDXUTComboBox *pCombo;
			r_HUD.m_GUI.AddComboBox( GetEnum(AMD_IDC_COMBOBOX_TARGET_ISA), iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, 0, true, &pCombo );

			if( pCombo )
			{
				pCombo->SetDropHeight( 300 );
				for( int i = AMD::FIRST_ISA_TARGET; i < AMD::NUM_ISA_TARGETS; ++i )
				{
					pCombo->AddItem( AMD::AmdTargetInfo[ i ].m_Name, NULL );
				}
				pCombo->SetSelectedByIndex( AMD::DEFAULT_ISA_TARGET );
			}
			r_HUD.m_GUI.AddStatic( GetEnum(AMD_IDC_STATIC_TARGET_ISA_INFO), L"Press (F6) to add New ISA", iSCElementOffset, iY += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight );
		}
#endif
	}

	SetHUDVisibility( r_HUD, i_bAdvancedShaderCacheGUI_VisibleByDefault );

	iY = i_old_iY + AMD::HUD::iElementDelta;
#endif
}