本文整理汇总了C++中CDXUTDialog::GetComboBox方法的典型用法代码示例。如果您正苦于以下问题:C++ CDXUTDialog::GetComboBox方法的具体用法?C++ CDXUTDialog::GetComboBox怎么用?C++ CDXUTDialog::GetComboBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDXUTDialog
的用法示例。
在下文中一共展示了CDXUTDialog::GetComboBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitApp
//--------------------------------------------------------------------------------------
// Initialize the app
//--------------------------------------------------------------------------------------
void InitApp()
{
//g_LightControl.SetLightDirection( D3DXVECTOR3(-0.29f, 0.557f, 0.778f) );
g_LightControl.SetLightDirection( D3DXVECTOR3( -0.789f, 0.527f, 0.316f ) );
g_LightControl.SetButtonMask( MOUSE_MIDDLE_BUTTON );
// Initialize dialogs
g_SettingsDlg.Init( &g_DialogResourceManager );
g_HUD.Init( &g_DialogResourceManager );
g_SampleUI.Init( &g_DialogResourceManager );
g_HUD.SetCallback( OnGUIEvent ); int iX = 15; int iY = 10;
g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", iX, iY, 125, 22 );
g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", iX, iY += 24, 125, 22 );
g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", iX, iY += 24, 125, 22, VK_F2 );
g_SampleUI.SetCallback( OnGUIEvent ); iX = 15; iY = 10;
// Title font for static
g_SampleUI.SetFont( 1, L"Arial", 14, FW_NORMAL );
CDXUTElement* pElement = g_SampleUI.GetDefaultElement( DXUT_CONTROL_STATIC, 0 );
if( pElement )
{
pElement->iFont = 1;
pElement->dwTextFormat = DT_RIGHT | DT_VCENTER;
}
// Technique
g_SampleUI.AddStatic( -1, L"Technique", iX, iY += 24, 115, 22 );
g_SampleUI.AddComboBox( IDC_TECHNIQUE, iX + 125, iY, 150, 22 );
g_SampleUI.GetComboBox( IDC_TECHNIQUE )->SetScrollBarWidth( 0 );
g_SampleUI.GetComboBox( IDC_TECHNIQUE )->AddItem( L"Local-deformable PRT", ( void* )"LDPRT" );
g_SampleUI.GetComboBox( IDC_TECHNIQUE )->AddItem( L"N dot L lighting", ( void* )"NdotL" );
// Animation speed
iY += 10;
g_SampleUI.AddStatic( -1, L"Animation Speed", iX, iY += 24, 115, 22 );
g_SampleUI.AddSlider( IDC_ANIMATION_SPEED, iX + 125, iY, 125, 22, 0, 3000, 700 );
// Light intensity
iY += 10;
g_SampleUI.AddStatic( -1, L"Light Intensity", iX, iY += 24, 115, 22 );
g_SampleUI.AddSlider( IDC_LIGHT_SLIDER, iX + 125, iY, 125, 22, 0, 1000, 500 );
g_SampleUI.AddStatic( IDC_ENV_LABEL, L"Env Intensity", iX, iY += 24, 115, 22 );
g_SampleUI.AddSlider( IDC_ENV_SLIDER, iX + 125, iY, 125, 22, 0, 3000, 600 );
// Color transmission
iY += 10;
g_SampleUI.AddStatic( IDC_RED_TRANSMIT_LABEL, L"Transmit Red", iX, iY += 24, 115, 22 );
g_SampleUI.AddSlider( IDC_RED_TRANSMIT_SLIDER, iX + 125, iY, 125, 22, 0, 3000, 1200 );
g_SampleUI.AddStatic( IDC_GREEN_TRANSMIT_LABEL, L"Transmit Green", iX, iY += 24, 115, 22 );
g_SampleUI.AddSlider( IDC_GREEN_TRANSMIT_SLIDER, iX + 125, iY, 125, 22, 0, 3000, 800 );
g_SampleUI.AddStatic( IDC_BLUE_TRANSMIT_LABEL, L"Transmit Blue", iX, iY += 24, 115, 22 );
g_SampleUI.AddSlider( IDC_BLUE_TRANSMIT_SLIDER, iX + 125, iY, 125, 22, 0, 3000, 350 );
}
示例2: 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;
}
}
}
}
示例3: 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 ) );
}
示例4: onKeyboard
void CALLBACK onKeyboard(UINT nchar, bool keyDown, bool altDown, void *userContext) {
if (keyDown)
switch (nchar) {
case VK_TAB: {
if (keyDown)
showHud = !showHud;
break;
}
case '1':
case '2':
case '3':
case '4':
case '5': {
hud.GetComboBox(IDC_PRESET)->SetSelectedByIndex(nchar - '1');
onLostDevice(NULL);
onResetDevice(DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL);
break;
}
case 'X':
hud.GetCheckBox(IDC_PROFILE)->SetChecked(!hud.GetCheckBox(IDC_PROFILE)->GetChecked());
timer->setEnabled(hud.GetCheckBox(IDC_PROFILE)->GetChecked());
break;
case 'Z':
hud.GetCheckBox(IDC_ANTIALIASING)->SetChecked(!hud.GetCheckBox(IDC_ANTIALIASING)->GetChecked());
break;
}
}
示例5: OnFrameRender
//--------------------------------------------------------------------------------------
// This callback function will be called at the end of every frame to perform all the
// rendering calls for the scene, and it will also be called if the window needs to be
// repainted. After this function has returned, DXUT will call
// IDirect3DDevice9::Present to display the contents of the next buffer in the swap chain
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameRender( IDirect3DDevice9* pd3dDevice, double fTime, float fElapsedTime, void* pUserContext )
{
// If the settings dialog is being shown, then
// render it instead of rendering the app's scene
if( g_SettingsDlg.IsActive() )
{
g_SettingsDlg.OnRender( fElapsedTime );
return;
}
HRESULT hr;
D3DXMATRIXA16 mWorld;
D3DXMATRIXA16 mView;
D3DXMATRIXA16 mProj;
D3DXMATRIXA16 mWorldViewProjection;
// Clear the render target and the zbuffer
V( pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 141, 153, 191 ), 1.0f, 0 ) );
// Render the scene
if( SUCCEEDED( pd3dDevice->BeginScene() ) )
{
// Get the projection & view matrix from the camera class
mWorld = *g_Camera.GetWorldMatrix();
mView = *g_Camera.GetViewMatrix();
mProj = *g_Camera.GetProjMatrix();
mWorldViewProjection = mWorld * mView * mProj;
// Update the effect's variables.
V( g_pEffect->SetMatrix( g_hWorldViewProjection, &mWorldViewProjection ) );
V( g_pEffect->SetMatrix( g_hWorld, &mWorld ) );
V( g_pEffect->SetFloat( g_hTime, ( float )fTime ) );
V( g_pEffect->SetValue( g_hCameraPosition, g_Camera.GetEyePt(), sizeof( D3DXVECTOR3 ) ) );
UINT iCurSubset = ( UINT )( INT_PTR )g_SampleUI.GetComboBox( IDC_SUBSET )->GetSelectedData();
// A subset of -1 was arbitrarily chosen to represent all subsets
if( iCurSubset == -1 )
{
// Iterate through subsets, changing material properties for each
for( UINT iSubset = 0; iSubset < g_MeshLoader.GetNumMaterials(); iSubset++ )
{
RenderSubset( iSubset );
}
}
else
{
RenderSubset( iCurSubset );
}
RenderText();
V( g_HUD.OnRender( fElapsedTime ) );
V( g_SampleUI.OnRender( fElapsedTime ) );
V( pd3dDevice->EndScene() );
}
}
示例6: initApp
void initApp() {
hud.Init(&dialogResourceManager);
hud.SetCallback(onGUIEvent); int iY = 10;
hud.AddButton(IDC_TOGGLE_FULLSCREEN, L"Toggle full screen", 35, iY, HUD_WIDTH, 22);
iY += 24;
hud.AddComboBox(IDC_PRESET, 35, iY += 24, HUD_WIDTH, 22, 0, false);
hud.GetComboBox(IDC_PRESET)->AddItem(L"SMAA Low", (LPVOID) 0);
hud.GetComboBox(IDC_PRESET)->AddItem(L"SMAA Medium", (LPVOID) 1);
hud.GetComboBox(IDC_PRESET)->AddItem(L"SMAA High", (LPVOID) 2);
hud.GetComboBox(IDC_PRESET)->AddItem(L"SMAA Ultra", (LPVOID) 3);
hud.GetComboBox(IDC_PRESET)->AddItem(L"SMAA Custom", (LPVOID) 4);
hud.GetComboBox(IDC_PRESET)->SetSelectedByData((LPVOID) 2);
hud.AddComboBox(IDC_DETECTION_MODE, 35, iY += 24, HUD_WIDTH, 22, 0, false);
hud.GetComboBox(IDC_DETECTION_MODE)->AddItem(L"Luma edge det.", (LPVOID) 0);
hud.GetComboBox(IDC_DETECTION_MODE)->AddItem(L"Color edge det.", (LPVOID) 1);
hud.GetComboBox(IDC_DETECTION_MODE)->AddItem(L"Depth edge det.", (LPVOID) 2);
hud.AddCheckBox(IDC_ANTIALIASING, L"SMAA Anti-Aliasing", 35, iY += 24, HUD_WIDTH, 22, true);
hud.AddCheckBox(IDC_PROFILE, L"Profile", 35, iY += 24, 125, 22, false);
wstringstream s;
s << L"Threshold: " << commandlineOptions.threshold;
hud.AddStatic(IDC_THRESHOLD_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22);
hud.AddSlider(IDC_THRESHOLD, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.threshold / 0.5f));
hud.GetStatic(IDC_THRESHOLD_LABEL)->SetVisible(false);
hud.GetSlider(IDC_THRESHOLD)->SetVisible(false);
s = wstringstream();
s << L"Max Search Steps: " << commandlineOptions.searchSteps;
hud.AddStatic(IDC_MAX_SEARCH_STEPS_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22);
hud.AddSlider(IDC_MAX_SEARCH_STEPS, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.searchSteps / 98.0f));
hud.GetStatic(IDC_MAX_SEARCH_STEPS_LABEL)->SetVisible(false);
hud.GetSlider(IDC_MAX_SEARCH_STEPS)->SetVisible(false);
s = wstringstream();
s << L"Max Diag. Search Steps: " << commandlineOptions.diagSearchSteps;
hud.AddStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22);
hud.AddSlider(IDC_MAX_SEARCH_STEPS_DIAG, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.diagSearchSteps / 20.0f));
hud.GetStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL)->SetVisible(false);
hud.GetSlider(IDC_MAX_SEARCH_STEPS_DIAG)->SetVisible(false);
s = wstringstream();
s << L"Corner Rounding: " << commandlineOptions.cornerRounding;
hud.AddStatic(IDC_CORNER_ROUNDING_LABEL, s.str().c_str(), 35, iY += 24, HUD_WIDTH, 22);
hud.AddSlider(IDC_CORNER_ROUNDING, 35, iY += 24, HUD_WIDTH, 22, 0, 100, int(100.0f * commandlineOptions.cornerRounding / 100.0f));
hud.GetStatic(IDC_CORNER_ROUNDING_LABEL)->SetVisible(false);
hud.GetSlider(IDC_CORNER_ROUNDING)->SetVisible(false);
}
示例7: 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));
}
示例8: OnKeyboard
//--------------------------------------------------------------------------------------
// Handle key presses
//--------------------------------------------------------------------------------------
void CALLBACK OnKeyboard( UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext )
{
switch (nChar)
{
case '1':
case '2':
case '3':
case '4':
{
int group = (nChar - '1');
auto pComboBox = g_SampleUI.GetComboBox( IDC_GROUP );
assert(pComboBox != NULL);
pComboBox->SetSelectedByData( IntToPtr( group ) );
SetViewForGroup( group );
}
break;
}
}
示例9: onResetDevice
HRESULT CALLBACK onResetDevice(IDirect3DDevice9 *device, const D3DSURFACE_DESC *desc, void *userContext) {
HRESULT hr;
V_RETURN(dialogResourceManager.OnD3D9ResetDevice());
if (font) V_RETURN(font->OnResetDevice());
timer = new Timer(device);
timer->setEnabled(hud.GetCheckBox(IDC_PROFILE)->GetChecked());
timer->setRepetitionsCount(100);
SMAA::Preset preset = SMAA::Preset(int(hud.GetComboBox(IDC_PRESET)->GetSelectedData()));
if(int(preset) == 4)
{
setVisibleCustomControls( true);
} else {
setVisibleCustomControls(false);
}
smaa = new SMAA(device, desc->Width, desc->Height, preset);
V(device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbufferSurface));
V(device->CreateTexture(desc->Width, desc->Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &finalbufferColorTex, NULL));
V(finalbufferColorTex->GetSurfaceLevel(0, &finalbufferColorSurface));
V(device->CreateTexture(desc->Width, desc->Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &finalbufferDepthTex, NULL));
V(finalbufferDepthTex->GetSurfaceLevel(0, &finalbufferDepthSurface));
D3DXIMAGE_INFO info;
V(D3DXGetImageInfoFromResource(NULL, L"Unigine02.png", &info));
V(D3DXCreateTextureFromResourceEx(device, NULL, L"Unigine02.png", info.Width, info.Height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0, &info, NULL, &colorTex));
V(D3DXGetImageInfoFromResource(NULL, L"Unigine02.dds", &info));
V(D3DXCreateTextureFromResourceEx(device, NULL, L"Unigine02.dds", info.Width, info.Height, 1, 0, D3DFMT_R32F, D3DPOOL_DEFAULT, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0, &info, NULL, &depthTex));
V_RETURN(D3DXCreateSprite(device, &sprite));
txtHelper = new CDXUTTextHelper(font, sprite, NULL, NULL, 15);
hud.SetLocation(desc->Width - 170, 0);
hud.SetSize(170, 170);
return S_OK;
}
示例10: 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));
}
示例11: CDXUTTextHelper
//--------------------------------------------------------------------------------------
// 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;
auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
V_RETURN( g_SettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
// Create other render resources here
g_States = std::make_unique<CommonStates>( pd3dDevice );
g_Batch = std::make_unique<PrimitiveBatch<VertexPositionColor>>( pd3dImmediateContext );
g_BatchEffect = std::make_unique<BasicEffect>( pd3dDevice );
g_BatchEffect->SetVertexColorEnabled(true);
{
void const* shaderByteCode;
size_t byteCodeLength;
g_BatchEffect->GetVertexShaderBytecode( &shaderByteCode, &byteCodeLength );
hr = pd3dDevice->CreateInputLayout( VertexPositionColor::InputElements,
VertexPositionColor::InputElementCount,
shaderByteCode, byteCodeLength,
&g_pBatchInputLayout );
if( FAILED( hr ) )
return hr;
}
// Setup the camera's view parameters
auto pComboBox = g_SampleUI.GetComboBox( IDC_GROUP );
SetViewForGroup( (pComboBox) ? (int)PtrToInt( pComboBox->GetSelectedData() ) : 0 );
g_HUD.GetButton( IDC_TOGGLEWARP )->SetEnabled( true );
return S_OK;
}
示例12: LoadRasterizerStates
//--------------------------------------------------------------------------------------
// LoadRasterizerStates
// Create a set of rasterizer states for non-FX state managment. These states
// will later be set using RSSetState in OnD3D10FrameRender.
//--------------------------------------------------------------------------------------
void LoadRasterizerStates( ID3D10Device* pd3dDevice )
{
D3D10_FILL_MODE fill[MAX_RASTERIZER_MODES] =
{
D3D10_FILL_SOLID,
D3D10_FILL_SOLID,
D3D10_FILL_SOLID,
D3D10_FILL_WIREFRAME,
D3D10_FILL_WIREFRAME,
D3D10_FILL_WIREFRAME
};
D3D10_CULL_MODE cull[MAX_RASTERIZER_MODES] =
{
D3D10_CULL_NONE,
D3D10_CULL_FRONT,
D3D10_CULL_BACK,
D3D10_CULL_NONE,
D3D10_CULL_FRONT,
D3D10_CULL_BACK
};
for( UINT i = 0; i < MAX_RASTERIZER_MODES; i++ )
{
D3D10_RASTERIZER_DESC rasterizerState;
rasterizerState.FillMode = fill[i];
rasterizerState.CullMode = cull[i];
rasterizerState.FrontCounterClockwise = false;
rasterizerState.DepthBias = false;
rasterizerState.DepthBiasClamp = 0;
rasterizerState.SlopeScaledDepthBias = 0;
rasterizerState.DepthClipEnable = true;
rasterizerState.ScissorEnable = false;
rasterizerState.MultisampleEnable = false;
rasterizerState.AntialiasedLineEnable = false;
pd3dDevice->CreateRasterizerState( &rasterizerState, &g_pRasterStates[i] );
g_SampleUI.GetComboBox( IDC_SCENERASTERIZER_MODE )->AddItem( g_szRasterizerModes[i], ( void* )( UINT64 )i );
}
}
示例13: onFrameRender
void CALLBACK onFrameRender(IDirect3DDevice9 *device, double time, float elapsedTime, void *userContext) {
HRESULT hr;
// IMPORTANT: stencil must be cleared to zero before executing 'smaa->go'
V(device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0));
V(device->BeginScene());
// This emulates main pass.
mainPass(device);
// Run SMAA
if (hud.GetCheckBox(IDC_ANTIALIASING)->GetChecked()) {
SMAA::Input input = SMAA::Input(int(hud.GetComboBox(IDC_DETECTION_MODE)->GetSelectedData()));
int n = hud.GetCheckBox(IDC_PROFILE)->GetChecked()? timer->getRepetitionsCount() : 1;
timer->start();
for (int i = 0; i < n; i++) { // This loop is just for profiling.
switch (input) {
case SMAA::INPUT_LUMA:
case SMAA::INPUT_COLOR:
smaa->go(finalbufferColorTex, finalbufferColorTex, backbufferSurface, input);
break;
case SMAA::INPUT_DEPTH:
smaa->go(finalbufferDepthTex, finalbufferColorTex, backbufferSurface, input);
break;
}
}
timer->clock(L"SMAA");
} else {
copy(device);
}
// Draw the HUD
drawHud(elapsedTime);
V(device->EndScene());
}
示例14: if
//--------------------------------------------------------------------------------------
// 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 );
//.........这里部分代码省略.........
示例15: 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;
}