本文整理汇总了C++中CDXUTComboBox类的典型用法代码示例。如果您正苦于以下问题:C++ CDXUTComboBox类的具体用法?C++ CDXUTComboBox怎么用?C++ CDXUTComboBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CDXUTComboBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateMSAASampleCounts
//--------------------------------------------------------------------------------------
// Update the MSAA sample count combo box for this format
//--------------------------------------------------------------------------------------
void UpdateMSAASampleCounts( ID3D10Device* pd3dDevice, DXGI_FORMAT fmt )
{
CDXUTComboBox* pComboBox = NULL;
bool bResetSampleCount = false;
UINT iHighestSampleCount = 0;
pComboBox = g_SampleUI.GetComboBox( IDC_SAMPLE_COUNT );
if( !pComboBox )
return;
pComboBox->RemoveAllItems();
WCHAR val[10];
for( UINT i = 1; i <= D3D10_MAX_MULTISAMPLE_SAMPLE_COUNT; i++ )
{
UINT Quality;
if( SUCCEEDED( pd3dDevice->CheckMultisampleQualityLevels( fmt, i, &Quality ) ) &&
Quality > 0 )
{
swprintf_s( val, 10, L"%d", i );
pComboBox->AddItem( val, IntToPtr( i ) );
iHighestSampleCount = i;
}
else if( g_MSAASampleCount == i )
{
bResetSampleCount = true;
}
}
if( bResetSampleCount )
g_MSAASampleCount = iHighestSampleCount;
pComboBox->SetSelectedByData( IntToPtr( g_MSAASampleCount ) );
}
示例2: OnGUIEvent
//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
CDXUTComboBox* pComboBox = NULL;
CDXUTComboBox* pAABBLevelComboBox = NULL;
switch( nControlID )
{
case IDC_TOGGLEFULLSCREEN:
DXUTToggleFullScreen(); break;
case IDC_TOGGLEWARP:
DXUTToggleWARP(); break;
case IDC_TOGGLEREF:
DXUTToggleREF(); break;
case IDC_CHANGEDEVICE:
g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break;
case IDC_SCENERASTERIZER_MODE:
//CDXUTComboBox* pComboBox = NULL;
pComboBox = ( CDXUTComboBox* )pControl;
g_eSceneRasterizerMode = ( UINT )PtrToInt( pComboBox->GetSelectedData() );
break;
case IDC_AABBSUBLEVEL:
pAABBLevelComboBox = ( CDXUTComboBox* )pControl;
g_CurrentAABBLevel = ( UINT )PtrToInt( pAABBLevelComboBox->GetSelectedData() );
break;
}
}
示例3: OnGUIEvent
//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
switch( nControlID )
{
case IDC_TOGGLEFULLSCREEN:
DXUTToggleFullScreen(); break;
case IDC_TOGGLEREF:
DXUTToggleREF(); break;
case IDC_CHANGEDEVICE:
g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break;
case IDC_TOGGLEWARP:
DXUTToggleWARP(); break;
case IDC_TOGGLE_BLUR:
g_bUseMotionBlur = !g_bUseMotionBlur;
break;
case IDC_RENDER_OGRE:
g_bRenderOgre = !g_bRenderOgre;
break;
case IDC_SAMPLE_COUNT:
{
CDXUTComboBox* pComboBox = ( CDXUTComboBox* )pControl;
g_MSAASampleCount = ( UINT )PtrToInt( pComboBox->GetSelectedData() );
HRESULT hr = S_OK;
ID3D10Device* pd3dDevice = DXUTGetD3D10Device();
if( pd3dDevice )
V( CreateRenderTarget( pd3dDevice, g_BackBufferWidth, g_BackBufferHeight, g_MSAASampleCount, 0 ) );
}
break;
}
}
示例4: OnKeyboard
// Handle key presses
void CALLBACK OnKeyboard( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext )
{
if( bKeyDown )
{
switch( nChar )
{
case VK_F1:
gShowHelp = !gShowHelp; break;
case VK_TAB:
{
CDXUTComboBox *comboBox = gSampleUI.GetComboBox(IDC_IMAGEVIEW);
if (eImageView_Uncompressed == (intptr_t)comboBox->GetSelectedData())
{
comboBox->SetSelectedByData((void*)eImageView_Compressed);
}
else if (eImageView_Compressed == (intptr_t)comboBox->GetSelectedData())
{
comboBox->SetSelectedByData((void*)eImageView_Uncompressed);
}
gSampleUI.SendEvent(IDC_IMAGEVIEW, true, comboBox);
break;
}
}
}
}
示例5: InitGUI
//--------------------------------------------------------------------------------------
//
//--------------------------------------------------------------------------------------
void InitGUI()
{
// Initialize dialogs
g_SettingsDlg.Init(&g_DialogResourceManager);
g_HUD.Init(&g_DialogResourceManager);
g_HUD.SetCallback(OnGUIEvent);
g_TextRenderer.Init(&g_DialogResourceManager);
int iY = 10;
g_HUD.AddButton (IDC_TOGGLEFULLSCREEN, L"Toggle full screen" , 35, iY, 160, 22);
g_HUD.AddButton (IDC_TOGGLEREF, L"Toggle REF (F3)" , 35, iY += 24, 160, 22, VK_F3);
g_HUD.AddButton (IDC_CHANGEDEVICE, L"Change device (F2)" , 35, iY += 24, 160, 22, VK_F2);
iY += 20;
g_HUD.AddCheckBox(IDC_DEINTERLEAVE, L"Deinterleaved Texturing", 35, iY += 28, 125, 22, g_UseDeinterleavedTexturing);
g_HUD.AddCheckBox(IDC_RANDOMIZE, L"Randomize Samples", 35, iY += 28, 125, 22, g_RandomizeSamples);
g_HUD.AddCheckBox(IDC_BLUR_AO, L"Blur AO", 35, iY += 28, 125, 22, g_BlurAO);
iY += 24;
CDXUTComboBox *pComboBox;
g_HUD.AddComboBox(IDC_CHANGESCENE, 35, iY += 24, 160, 22, 'M', false, &pComboBox);
for (int i = 0; i < ARRAYSIZE(g_MeshDesc); i++)
{
pComboBox->AddItem(g_MeshDesc[i].Name, NULL);
}
iY += 24;
WCHAR sz[100];
int dy = 20;
StringCchPrintf(sz, 100, UI_RADIUS_MULT L"%0.2f", g_AOParams.Radius);
g_HUD.AddStatic(IDC_RADIUS_STATIC, sz, 35, iY += dy, 125, 22);
g_HUD.AddSlider(IDC_RADIUS_SLIDER, 50, iY += dy, 100, 22, 0, 100, int(g_AOParams.Radius / MAX_RADIUS_MULT * 100));
StringCchPrintf(sz, 100, UI_AO_BIAS L"%g", g_AOParams.Bias);
g_HUD.AddStatic(IDC_BIAS_STATIC, sz, 35, iY += dy, 125, 22);
g_HUD.AddSlider(IDC_BIAS_SLIDER, 50, iY += dy, 100, 22, 0, 500, int(g_AOParams.Bias * 1000));
StringCchPrintf(sz, 100, UI_POW_EXPONENT L"%0.2f", g_AOParams.PowerExponent);
g_HUD.AddStatic(IDC_EXPONENT_STATIC, sz, 35, iY += dy, 125, 22);
g_HUD.AddSlider(IDC_EXPONENT_SLIDER, 50, iY += dy, 100, 22, 0, 400, (int)(100.0f*g_AOParams.PowerExponent));
StringCchPrintf(sz, 100, UI_BLUR_SHARPNESS L"%0.2f", g_AOParams.Blur.Sharpness);
g_HUD.AddStatic(IDC_BLUR_SHARPNESS_STATIC, sz, 35, iY += dy, 125, 22);
g_HUD.AddSlider(IDC_BLUR_SHARPNESS_SLIDER, 50, iY += dy, 100, 22, 0, 1600, (int)(100.0f*g_AOParams.Blur.Sharpness));
UINT ButtonGroup = 0;
iY += 24;
g_HUD.AddRadioButton( IDC_1xMSAA, ButtonGroup, L"1X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_1X) );
g_HUD.AddRadioButton( IDC_2xMSAA, ButtonGroup, L"2X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_2X) );
g_HUD.AddRadioButton( IDC_4xMSAA, ButtonGroup, L"4X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_4X) );
g_HUD.AddRadioButton( IDC_8xMSAA, ButtonGroup, L"8X MSAA", 35, iY += 24, 125, 22, (g_MSAACurrentSettings == MSAA_MODE_8X) );
++ButtonGroup;
iY += 24;
g_HUD.AddRadioButton( IDC_PER_PIXEL_AO, ButtonGroup, L"PER_PIXEL_AO", 35, iY += 24, 125, 22, (g_AOParams.Output.MSAAMode == GFSDK_SSAO_PER_PIXEL_AO) );
g_HUD.AddRadioButton( IDC_PER_SAMPLE_AO, ButtonGroup, L"PER_SAMPLE_AO", 35, iY += 24, 125, 22, (g_AOParams.Output.MSAAMode == GFSDK_SSAO_PER_SAMPLE_AO) );
}
示例6: InitApp
// Initialize the app
void InitApp()
{
// Initialize dialogs
gD3DSettingsDlg.Init(&gDialogResourceManager);
gHUD.Init(&gDialogResourceManager);
gSampleUI.Init(&gDialogResourceManager);
gHUD.SetCallback(OnGUIEvent);
int x = 0;
int y = 10;
gHUD.AddButton(IDC_TOGGLEFULLSCREEN, L"Toggle full screen", x, y, 170, 23);
gHUD.AddButton(IDC_TOGGLEREF, L"Toggle REF (F3)", x, y += 26, 170, 23, VK_F3);
gHUD.AddButton(IDC_CHANGEDEVICE, L"Change device (F2)", x, y += 26, 170, 23, VK_F2);
gHUD.SetSize( 170, 170 );
gSampleUI.SetCallback(OnGUIEvent);
x = 0;
y = 0;
gSampleUI.AddStatic(IDC_TEXT, L"", x, y, 1, 1); y += 5*22;
gSampleUI.AddComboBox(IDC_PROFILE, x, y, 226, 22); y += 26;
gSampleUI.AddCheckBox(IDC_MT, L"Multithreaded", x, y, 125, 22, gMultithreaded);
gSampleUI.AddButton(IDC_RECOMPRESS, L"Recompress", x + 131, y, 125, 22); y += 26;
gSampleUI.AddComboBox(IDC_IMAGEVIEW, x, y, 145, 22);
gSampleUI.AddCheckBox(IDC_ALPHA, L"Show Alpha", x + 151, y, 105, 22); y += 26;
gSampleUI.AddSlider(IDC_EXPOSURE, x, y, 250, 22); y += 26;
gSampleUI.AddButton(IDC_LOAD_TEXTURE, L"Load Texture", x, y, 125, 22);
gSampleUI.AddButton(IDC_SAVE_TEXTURE, L"Save Texture", x + 131, y, 125, 22); y += 26;
gSampleUI.SetSize( 276, y+150 );
{
CDXUTComboBox *comboBox = gSampleUI.GetComboBox(IDC_IMAGEVIEW);
comboBox->AddItem(L"Uncompressed", (void *)(eImageView_Uncompressed));
comboBox->AddItem(L"Compressed", (void *)(eImageView_Compressed));
//comboBox->AddItem(L"Error", (void *)(eImageView_Error));
//comboBox->AddItem(L"All", (void *)(eImageView_All));
comboBox->SetSelectedByData((void *)(gImageView));
}
gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT));
}
示例7: device
void CmDxBase::InitApp()
{
_SettingsDlg.Init( &s_DlgRscManager);
_HUD.Init( &s_DlgRscManager);
_SampleUI.Init( &s_DlgRscManager);
_HUD.SetCallback(OnGUIEvent, this);
int iY = 30;
int iYo = 26;
_HUD.AddButton(IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 0, iY, 170, 22 );
_HUD.AddButton(IDC_CHANGEDEVICE, L"Change device (F2)", 0, iY += iYo, 170, 22, VK_F2 );
_HUD.AddButton(IDC_TOGGLEREF, L"Toggle REF (F3)", 0, iY += iYo, 170, 22, VK_F3 );
_HUD.AddButton(IDC_TOGGLEWARP, L"Toggle WARP (F4)", 0, iY += iYo, 170, 22, VK_F4 );
// Create sample UI
CDXUTComboBox* pComboBox = nullptr;
_SampleUI.AddStatic( IDC_STATIC, L"Group", 10, 0, 170, 25 );
_SampleUI.AddComboBox( IDC_GROUP, 0, 25, 170, 24, 'G', false, &pComboBox );
if( pComboBox )
pComboBox->SetDropHeight( 50 );
pComboBox->AddItem( L"Frustum", IntToPtr( 0 ) );
pComboBox->AddItem( L"Axis-aligned Box", IntToPtr( 1 ) );
pComboBox->AddItem( L"Oriented Box", IntToPtr( 2 ) );
pComboBox->AddItem( L"Ray", IntToPtr( 3 ) );
_SampleUI.AddStatic(IDC_SLIDER_STATIC, L"Slider", 0, 50, 10, 25);
_SampleUI.AddSlider(IDC_SLIDER, 55, 50, 100, 20, 0, 100, 50, false);
_SampleUI.SetCallback(OnGUIEvent, this);
}
示例8: InitApp
//--------------------------------------------------------------------------------------
// Initialize the app
//--------------------------------------------------------------------------------------
void InitApp()
{
g_SettingsDlg.Init( &g_DialogResourceManager );
g_HUD.Init( &g_DialogResourceManager );
g_SampleUI.Init( &g_DialogResourceManager );
g_HUD.SetCallback( OnGUIEvent );
int iY = 30;
int iYo = 26;
g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 0, iY, 170, 22 );
g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 0, iY += iYo, 170, 22, VK_F2 );
g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", 0, iY += iYo, 170, 22, VK_F3 );
g_HUD.AddButton( IDC_TOGGLEWARP, L"Toggle WARP (F4)", 0, iY += iYo, 170, 22, VK_F4 );
g_SampleUI.SetCallback( OnGUIEvent );
CDXUTComboBox* pComboBox = nullptr;
g_SampleUI.AddStatic( IDC_STATIC, L"(G)roup", 10, 0, 170, 25 );
g_SampleUI.AddComboBox( IDC_GROUP, 0, 25, 170, 24, 'G', false, &pComboBox );
if( pComboBox )
pComboBox->SetDropHeight( 50 );
pComboBox->AddItem( L"Frustum", IntToPtr( 0 ) );
pComboBox->AddItem( L"Axis-aligned Box", IntToPtr( 1 ) );
pComboBox->AddItem( L"Oriented Box", IntToPtr( 2 ) );
pComboBox->AddItem( L"Ray", IntToPtr( 3 ) );
InitializeObjects();
}
示例9: FillProfiles
void FillProfiles(BOOL DX11Available)
{
CDXUTComboBox *comboBox = gSampleUI.GetComboBox(IDC_PROFILE);
if (DX11Available)
{
comboBox->AddItem(L"BC6H veryfast", (void *)(CompressImageBC6H_veryfast));
comboBox->AddItem(L"BC6H fast", (void *)(CompressImageBC6H_fast));
comboBox->AddItem(L"BC6H basic", (void *)(CompressImageBC6H_basic));
comboBox->AddItem(L"BC6H slow", (void *)(CompressImageBC6H_slow));
comboBox->AddItem(L"BC6H veryslow", (void *)(CompressImageBC6H_veryslow));
comboBox->SetDropHeight((12-1)*17);
}
comboBox->SetSelectedByData((void *)(gCompressionFunc));
}
示例10: InitApp
//--------------------------------------------------------------------------------------
// Initialize the app
//--------------------------------------------------------------------------------------
void InitApp()
{
g_D3DSettingsDlg.Init( &g_DialogResourceManager );
g_HUD.Init( &g_DialogResourceManager );
g_SampleUI.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_CHANGEDEVICE, L"Change device (F2)", 35, iY += 24, 125, 22, VK_F2 );
g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", 35, iY += 24, 125, 22, VK_F3 );
g_HUD.AddButton( IDC_TOGGLEWARP, L"Toggle WARP (F4)", 35, iY += 24, 125, 22, VK_F4 );
g_SampleUI.SetCallback( OnGUIEvent ); iY = 10;
CDXUTCheckBox* pCheckBox = NULL;
g_SampleUI.AddCheckBox( IDC_TOGGLE_BLUR, L"Use Motion Blur", 0, 105, 140, 24, true, 0, false, &pCheckBox );
g_SampleUI.AddCheckBox( IDC_RENDER_OGRE, L"Render Ogre", 0, 129, 140, 24, true, 0, false, &pCheckBox );
g_SampleUI.AddStatic( IDC_STATIC, L"MSAA (S)amples", 0, 180, 105, 25 );
CDXUTComboBox* pComboBox = NULL;
g_SampleUI.AddComboBox( IDC_SAMPLE_COUNT, 0, 205, 140, 24, 'S', false, &pComboBox );
if( pComboBox )
pComboBox->SetDropHeight( 30 );
}
示例11: OnD3D9CreateDevice
//--------------------------------------------------------------------------------------
// 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;
}
示例12: OnCreateDevice
//--------------------------------------------------------------------------------------
// This callback function will be called immediately after the Direct3D device has been
// created, which will happen during application initialization and windowed/full screen
// toggles. This is the best location to create D3DPOOL_MANAGED resources since these
// resources need to be reloaded whenever the device is destroyed. Resources created
// here should be released in the OnDestroyDevice callback.
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
WCHAR str[MAX_PATH];
V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );
// Initialize the font
V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont ) );
// Create the mesh and load it with data already gathered from a file
V_RETURN( g_MeshLoader.Create( pd3dDevice, L"media\\cup.obj" ) );
// Add the identified material subsets to the UI
CDXUTComboBox* pComboBox = g_SampleUI.GetComboBox( IDC_SUBSET );
pComboBox->RemoveAllItems();
pComboBox->AddItem( L"All", ( void* )( INT_PTR )-1 );
for( UINT i = 0; i < g_MeshLoader.GetNumMaterials(); i++ )
{
Material* pMaterial = g_MeshLoader.GetMaterial( i );
pComboBox->AddItem( pMaterial->strName, ( void* )( INT_PTR )i );
}
// Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the
// shader debugger. Debugging vertex shaders requires either REF or software vertex
// processing, and debugging pixel shaders requires REF. The
// D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug experience in the
// shader debugger. It enables source level debugging, prevents instruction
// reordering, prevents dead code elimination, and forces the compiler to compile
// against the next higher available software target, which ensures that the
// unoptimized shaders do not exceed the shader model limitations. Setting these
// flags will cause slower rendering since the shaders will be unoptimized and
// forced into software. See the DirectX documentation for more information about
// using the shader debugger.
DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3DXSHADER_DEBUG;
#endif
#ifdef DEBUG_VS
dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif
// Read the D3DX effect file
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"MeshFromOBJ.fx" ) );
// If this fails, there should be debug output as to
// they the .fx file failed to compile
V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags,
NULL, &g_pEffect, NULL ) );
// Cache the effect handles
g_hAmbient = g_pEffect->GetParameterBySemantic( 0, "Ambient" );
g_hDiffuse = g_pEffect->GetParameterBySemantic( 0, "Diffuse" );
g_hSpecular = g_pEffect->GetParameterBySemantic( 0, "Specular" );
g_hOpacity = g_pEffect->GetParameterBySemantic( 0, "Opacity" );
g_hSpecularPower = g_pEffect->GetParameterBySemantic( 0, "SpecularPower" );
g_hLightColor = g_pEffect->GetParameterBySemantic( 0, "LightColor" );
g_hLightPosition = g_pEffect->GetParameterBySemantic( 0, "LightPosition" );
g_hCameraPosition = g_pEffect->GetParameterBySemantic( 0, "CameraPosition" );
g_hTexture = g_pEffect->GetParameterBySemantic( 0, "Texture" );
g_hTime = g_pEffect->GetParameterBySemantic( 0, "Time" );
g_hWorld = g_pEffect->GetParameterBySemantic( 0, "World" );
g_hWorldViewProjection = g_pEffect->GetParameterBySemantic( 0, "WorldViewProjection" );
// Setup the camera's view parameters
D3DXVECTOR3 vecEye( 2.0f, 1.0f, 0.0f );
D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );
g_Camera.SetViewParams( &vecEye, &vecAt );
return S_OK;
}
示例13: InitApp
static void InitApp()
{
g_pCamManager = new S3UTCameraManager();
g_pCamManager->ConfigCameras("Cameras.txt");
g_pCamManager->DumpCameraStatus("DumpResult.txt");
g_D3DSettingsDlg.Init( &g_DialogResourceManager );
g_HUD.Init( &g_DialogResourceManager );
g_SampleUI.Init( &g_DialogResourceManager );
g_HUD.SetCallback( OnGUIEvent ); int iY = 10;
g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 35, iY, 125, 22, VK_F2 );
g_SampleUI.EnableKeyboardInput( true );
g_SampleUI.SetCallback( OnGUIEvent );
iY = 10;
g_SampleUI.AddStatic( IDC_SHADOW_ALGORITHM_LABEL, L"Shadow algorithm:", 35, iY, 125, 22 );
CDXUTComboBox *pComboBox;
g_SampleUI.AddComboBox( IDC_SHADOW_ALGORITHM, 35, iY += 20, 125, 30, 0, false, &pComboBox);
pComboBox->AddItem(L"StandardBP", NULL);
pComboBox->AddItem(L"BP_MSSM_KERNEL", NULL);
pComboBox->AddItem(L"STD_VSM", NULL);
pComboBox->AddItem(L"MipVSM", NULL);
pComboBox->AddItem(L"HirBP", NULL);
pComboBox->AddItem(L"BPGI", NULL);
pComboBox->AddItem(L"NoShadows", NULL);
pComboBox->AddItem(L"SingleLight", NULL);
pComboBox->AddItem(L"PCSS", NULL);
g_SampleUI.AddStatic( IDC_COMMON_LABEL, L"Light Zn", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider( IDC_LIGHT_ZN, 160, iY, 124, 22, 0, 100, g_fCtrledLightZn*5 );
g_SampleUI.AddStatic( IDC_COMMON_LABEL, L"Light Zf", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider( IDC_LIGHT_ZF, 160, iY, 124, 22, 0, 100, g_fCtrledLightZf - 10 );
g_SampleUI.AddStatic( IDC_COMMON_LABEL, L"Light FOV", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider( IDC_LIGHT_FOV, 160, iY, 124, 22, 0, 100, g_fCtrledLightFov * 100 );
g_SampleUI.AddStatic( IDC_LIGHT_SIZE_LABEL, L"Light source size:", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider( IDC_LIGHT_SIZE, 160, iY, 124, 22, 0, 100, 0 );
g_SampleUI.AddStatic(IDC_COMMON_LABEL, L"NumLightSample", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider(IDC_NUM_LIGHT_SAMPLE, 160, iY, 124, 22, 0, 16, 0 );
g_SampleUI.AddStatic(IDC_COMMON_LABEL, L"fDefaultDepthBias", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider(IDC_fDefaultDepthBias, 160, iY, 124, 22, 0, 100, 40 );
g_SampleUI.AddStatic(IDC_COMMON_LABEL, L"3rd depth delta", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider(IDC_BIAS_3RD_DEPTH, 160, iY, 124, 22, 0, 100, 40 );
g_SampleUI.AddStatic(IDC_COMMON_LABEL, L"1st depth delta", 35, iY += 25, 125, 22 );
g_SampleUI.AddSlider(IDC_BIAS_1ST_DEPTH, 160, iY, 124, 22, 0, 100, 40 );
g_SampleUI.AddCheckBox( IDC_BTEXTURED, L"Enable Texturing", 15, iY += 25, 124, 22, false);
g_SampleUI.AddCheckBox( IDC_SHOW_3DWIDGET, L"Show 3D Widget", 150, iY, 124, 22, true);
g_SampleUI.AddCheckBox( IDC_BMOVECAMERA, L"Move Camera", 15, iY += 25, 124, 22, true);
g_SampleUI.AddCheckBox( IDC_FRAME_DUMP, L"Dump Frame", 150, iY, 124, 22, false);
g_SampleUI.AddCheckBox( IDC_BDUMP_SHADOWMAP, L"Dump Shadow Map", 15, iY+=25, 124, 22, false);
g_SampleUI.AddCheckBox( IDC_BDUMP_LIGHT_PAR, L"Dump Light Para", 150, iY, 124, 22, false);
g_SampleUI.AddCheckBox( IDC_STATIC, L"Freeze Model", 15, iY += 25, 124, 22, false);
g_SampleUI.AddCheckBox( IDC_ANIMATE, L"Show Animated Model", 150, iY, 124, 22, false);
g_SampleUI.AddCheckBox( IDC_SCENE, L"Show scene", 15, iY += 25, 124, 22, true);
g_SampleUI.AddCheckBox( IDC_FAN, L"Show Fan", 150, iY, 124, 22, false);
g_CameraUI.Init( &g_DialogResourceManager );
g_CameraUI.EnableKeyboardInput( true );
g_CameraUI.SetCallback( OnGUIEvent );
{
g_pCamManager->SetupCameraUI( g_CameraUI );
}
}
示例14: gOnUIPageEvent
//==================================================================================
void CALLBACK gOnUIPageEvent( UINT nEvent, NxI32 nControlID, CDXUTControl* pControl )
{
CDXUTDialog *dialog = pControl->m_pDialog;
void *userdata = dialog->GetUserData();
if ( userdata )
{
TuiElement *page = (TuiElement *) userdata;
TextUserInterface *tui = gTui;
if ( page )
{
TuiElement *ret = page->GetElement( nControlID-1 );
switch ( ret->GetType() )
{
case TT_MULTI_SELECT:
{
switch( nEvent )
{
case EVENT_LISTBOX_ITEM_DBLCLK:
{
//DXUTListBoxItem *pItem = ((CDXUTListBox *)pControl)->GetItem( ((CDXUTListBox *)pControl)->GetSelectedIndex( -1 ) );
break;
}
case EVENT_LISTBOX_SELECTION:
{
CDXUTListBox *pListBox = (CDXUTListBox *)pControl;
TuiChoiceVector &choices = ret->GetChoices();
NxI32 count = (NxI32)choices.size();
for (NxI32 i=0; i<count; i++)
{
DXUTListBoxItem *item = pListBox->GetItem(i);
TuiChoice &choice = choices[i];
assert(item);
if ( item )
{
if ( choice.GetState() != item->bSelected )
{
choice.SetState(item->bSelected);
const char *args[2];
args[0] = choice.GetArg().Get();
if ( choice.GetState() )
args[1] = "true";
else
args[1] = "false";
page->ExecuteElement( nControlID-1, 2, args, tui, false );
}
}
}
}
}
}
break;
case TT_SLIDER:
{
CDXUTSlider *slider = (CDXUTSlider *) pControl;
NxI32 v = slider->GetValue();
NxF32 fv = ret->GetSliderValue(v);
char scratch[512];
sprintf(scratch,"%0.3f", fv );
const char *args[1];
args[0] = scratch;
page->ExecuteElement( nControlID-1, 1, args, tui, false );
}
break;
case TT_COMBO:
{
CDXUTComboBox *combo = (CDXUTComboBox *) pControl;
DXUTComboBoxItem *pItem = combo->GetSelectedItem();
wchar_t *string = pItem->strText;
char scratch[512];
wcstombs(scratch, string, 512 );
const char *args[1];
args[0] = scratch;
page->ExecuteElement( nControlID-1, 1, args,tui, false );
// now, do we need to hide any items (or show them)?
page->OnComboBoxChange( scratch, nControlID-1 );
}
break;
case TT_BUTTON:
case TT_PAGE:
page->ExecuteElement( nControlID-1, 0, 0, tui, false );
break;
case TT_CHECKBOX:
{
CDXUTCheckBox *pCheck = (CDXUTCheckBox *)pControl;
bool state = pCheck->GetChecked();
const char *args[1];
if ( state )
{
args[0] = "true";
}
else
//.........这里部分代码省略.........
示例15: OnD3D10CreateDevice
//--------------------------------------------------------------------------------------
// Create any D3D10 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBufferSurfaceDesc,
void* pUserContext )
{
HRESULT hr;
V_RETURN( g_DialogResourceManager.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( g_SettingsDlg.OnD3D10CreateDevice( pd3dDevice ) );
V_RETURN( D3DX10CreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
L"Arial", &g_pFont10 ) );
V_RETURN( D3DX10CreateSprite( pd3dDevice, 512, &g_pSprite10 ) );
g_pTxtHelper = new CDXUTTextHelper( NULL, NULL, g_pFont10, g_pSprite10, 15 );
// Read the D3DX effect file
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"MeshFromOBJ10.fx" ) );
DWORD dwShaderFlags = D3D10_SHADER_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
// Set the D3D10_SHADER_DEBUG flag to embed debug information in the shaders.
// Setting this flag improves the shader debugging experience, but still allows
// the shaders to be optimized and to run exactly the way they will run in
// the release configuration of this program.
dwShaderFlags |= D3D10_SHADER_DEBUG;
#endif
V_RETURN( D3DX10CreateEffectFromFile( str, NULL, NULL, "fx_4_0", dwShaderFlags, 0, pd3dDevice, NULL,
NULL, &g_pEffect10, NULL, NULL ) );
// Obtain the technique
g_pTechnique = g_pEffect10->GetTechniqueByName( "NoSpecular" );
g_ptxDiffuseVariable = g_pEffect10->GetVariableByName( "g_MeshTexture" )->AsShaderResource();
g_pAmbient = g_pEffect10->GetVariableByName( "g_vMaterialAmbient" )->AsVector();
g_pDiffuse = g_pEffect10->GetVariableByName( "g_vMaterialDiffuse" )->AsVector();
g_pSpecular = g_pEffect10->GetVariableByName( "g_vMaterialSpecular" )->AsVector();
g_pOpacity = g_pEffect10->GetVariableByName( "g_fMaterialAlpha" )->AsScalar();
g_pSpecularPower = g_pEffect10->GetVariableByName( "g_nMaterialShininess" )->AsScalar();
g_pLightColor = g_pEffect10->GetVariableByName( "g_vLightColor" )->AsVector();
g_pLightPosition = g_pEffect10->GetVariableByName( "g_vLightPosition" )->AsVector();
g_pCameraPosition = g_pEffect10->GetVariableByName( "g_vCameraPosition" )->AsVector();
g_pTime = g_pEffect10->GetVariableByName( "g_fTime" )->AsScalar();
g_pWorld = g_pEffect10->GetVariableByName( "g_mWorld" )->AsMatrix();
g_pWorldViewProjection = g_pEffect10->GetVariableByName( "g_mWorldViewProjection" )->AsMatrix();
// Define the input layout
const D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "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 },
} ;
UINT numElements = sizeof( layout ) / sizeof( layout[0] );
// Create the input layout
D3D10_PASS_DESC PassDesc;
g_pTechnique->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( layout, numElements, PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pVertexLayout ) );
pd3dDevice->IASetInputLayout( g_pVertexLayout );
// Load the mesh
V_RETURN( g_MeshLoader.Create( pd3dDevice, L"media\\cup.obj" ) );
// Add the identified subsets to the UI
CDXUTComboBox* pComboBox = g_SampleUI.GetComboBox( IDC_SUBSET );
pComboBox->RemoveAllItems();
pComboBox->AddItem( L"All", ( void* )( INT_PTR )-1 );
for ( UINT subset = 0; subset < g_MeshLoader.GetNumSubsets(); ++subset )
{
Material* pMaterial = g_MeshLoader.GetSubsetMaterial( subset );
pComboBox->AddItem( pMaterial->strName, ( void* )( INT_PTR )subset );
}
// Store the correct technique for each material
for ( UINT i = 0; i < g_MeshLoader.GetNumMaterials(); ++i )
{
Material* pMaterial = g_MeshLoader.GetMaterial( i );
const char* strTechnique = "";
if( pMaterial->pTextureRV10 && pMaterial->bSpecular )
strTechnique = "TexturedSpecular";
else if( pMaterial->pTextureRV10 && !pMaterial->bSpecular )
strTechnique = "TexturedNoSpecular";
else if( !pMaterial->pTextureRV10 && pMaterial->bSpecular )
strTechnique = "Specular";
else if( !pMaterial->pTextureRV10 && !pMaterial->bSpecular )
strTechnique = "NoSpecular";
pMaterial->pTechnique = g_pEffect10->GetTechniqueByName( strTechnique );
}
// Setup the camera's view parameters
D3DXVECTOR3 vecEye( 2.0f, 1.0f, 0.0f );
//.........这里部分代码省略.........