本文整理汇总了C++中CDXUTDialog::GetCheckBox方法的典型用法代码示例。如果您正苦于以下问题:C++ CDXUTDialog::GetCheckBox方法的具体用法?C++ CDXUTDialog::GetCheckBox怎么用?C++ CDXUTDialog::GetCheckBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDXUTDialog
的用法示例。
在下文中一共展示了CDXUTDialog::GetCheckBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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_TOGGLESPIN:
{
g_bSpinning = g_SampleUI.GetCheckBox( IDC_TOGGLESPIN )->GetChecked();
break;
}
case IDC_EXPLODE_SCALE:
{
WCHAR sz[100];
g_fExplode = ( float )( g_SampleUI.GetSlider( IDC_EXPLODE_SCALE )->GetValue() * 0.01f );
swprintf_s( sz, 100, L"Explode Amount: %0.2f", g_fExplode );
g_SampleUI.GetStatic( IDC_EXPLODE_STATIC )->SetText( sz );
g_pExplodeVariable->SetFloat( g_fExplode );
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_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break;
case IDC_ENABLE_PRESHADER:
{
g_bEnablePreshader = g_SampleUI.GetCheckBox( IDC_ENABLE_PRESHADER )->GetChecked();
if( DXUTGetD3D9Device() != NULL )
{
OnLostDevice( NULL );
OnDestroyDevice( NULL );
OnCreateDevice( DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL );
OnResetDevice( DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL );
}
break;
}
case IDC_ACTIVE_LIGHT:
if( !g_LightControl[g_nActiveLight].IsBeingDragged() )
{
g_nActiveLight++;
g_nActiveLight %= g_nNumActiveLights;
}
break;
case IDC_NUM_LIGHTS:
if( !g_LightControl[g_nActiveLight].IsBeingDragged() )
{
WCHAR sz[100];
swprintf_s( sz, 100, L"# Lights: %d", g_SampleUI.GetSlider( IDC_NUM_LIGHTS )->GetValue() );
g_SampleUI.GetStatic( IDC_NUM_LIGHTS_STATIC )->SetText( sz );
g_nNumActiveLights = g_SampleUI.GetSlider( IDC_NUM_LIGHTS )->GetValue();
g_nActiveLight %= g_nNumActiveLights;
}
break;
case IDC_LIGHT_SCALE:
g_fLightScale = ( float )( g_SampleUI.GetSlider( IDC_LIGHT_SCALE )->GetValue() * 0.10f );
WCHAR sz[100];
swprintf_s( sz, 100, L"Light scale: %0.2f", g_fLightScale );
g_SampleUI.GetStatic( IDC_LIGHT_SCALE_STATIC )->SetText( sz );
break;
}
}
示例4: OnKeyboard
//--------------------------------------------------------------------------------------
// Handle key presses
//--------------------------------------------------------------------------------------
void CALLBACK OnKeyboard(UINT nChar, bool bKeyDown, bool bAltDown, void* pUserContext)
{
if( !bKeyDown ) return;
if( g_SampleUI.GetCheckBox(IDC_BMOVECAMERA)->GetChecked() )
{
g_pCamManager->OnKeyboard(nChar,bKeyDown, bAltDown, pUserContext);
}
else
{
g_LCamera[0].OnKeyboard(nChar,bKeyDown, bAltDown, pUserContext);
}
switch( nChar )
{
case VK_F1:
g_bShowUI = !g_bShowUI;
break;
case VK_F3:
g_bShowLightUI = !g_bShowLightUI;
break;
case VK_F7:
g_LightVary = !g_LightVary;
break;
case VK_F8:
g_CameraMove = !g_CameraMove;
break;
case VK_F9:
g_LightMove = !g_LightMove;
break;
case VK_F10:
ssmap.m_bShaderChanged = true;
g_Final.m_bShaderChanged = true;
g_Widget.m_bShaderChanged = true;
if( ShadowAlgorithm == STD_VSM )
{
g_StdVSM.m_bShaderChanged = true;
}
if( ShadowAlgorithm == STD_PCSS )
{
g_PCSS.m_bShaderChanged = true;
}
if( ShadowAlgorithm == MIP_VSM )
{
g_MipVSM.m_bShaderChanged = true;
}
break;
default:
break;
}
}
示例5: 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());
}
示例6: MsgProc
//--------------------------------------------------------------------------------------
// Handle messages to the application
//--------------------------------------------------------------------------------------
LRESULT CALLBACK MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, bool* pbNoFurtherProcessing, void* pUserContext )
{
// Pass messages to dialog resource manager calls so GUI state is updated correctly
*pbNoFurtherProcessing = g_DialogResourceManager.MsgProc( hWnd, uMsg, wParam, lParam );
if( *pbNoFurtherProcessing )
return 0;
// Pass messages to settings dialog if its active
if( g_D3DSettingsDlg.IsActive() )
{
g_D3DSettingsDlg.MsgProc( hWnd, uMsg, wParam, lParam );
return 0;
}
// Give the dialogs a chance to handle the message first
*pbNoFurtherProcessing = g_HUD.MsgProc( hWnd, uMsg, wParam, lParam );
if( *pbNoFurtherProcessing )
return 0;
*pbNoFurtherProcessing = g_SampleUI.MsgProc( hWnd, uMsg, wParam, lParam );
if( *pbNoFurtherProcessing )
return 0;
if( g_bShowLightUI )
*pbNoFurtherProcessing = g_CameraUI.MsgProc( hWnd, uMsg, wParam, lParam );
// Pass all remaining windows messages to camera so it can respond to user input
unsigned iTmp = g_SampleUI.GetCheckBox(IDC_BMOVECAMERA)->GetChecked();
if ( iTmp ) // left button pressed
{
g_pCamManager->HandleMessages( hWnd, uMsg, wParam, lParam );
}
else{
//light management
for( int light_idx = 0; light_idx < 1/*NUM_LIGHT*/; ++ light_idx )
{
g_LCamera[light_idx].HandleMessages( hWnd, uMsg, wParam, lParam );
}
}
return 0;
}
示例7: 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;
}
示例8: OnGUIEvent
//--------------------------------------------------------------------------------------
// Handles the GUI events
//--------------------------------------------------------------------------------------
void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
switch( nControlID )
{
// Standard DXUT controls
case IDC_TOGGLEFULLSCREEN:
DXUTToggleFullScreen(); break;
case IDC_TOGGLEREF:
DXUTToggleREF(); break;
case IDC_CHANGEDEVICE:
g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break;
// Custom app controls
case IDC_PATCH_SUBDIVS:
{
g_fSubdivs = g_SampleUI.GetSlider( IDC_PATCH_SUBDIVS )->GetValue() / 10.0f;
WCHAR sz[100];
swprintf_s( sz, L"Patch Divisions: %2.1f", g_fSubdivs );
g_SampleUI.GetStatic( IDC_PATCH_SUBDIVS_STATIC )->SetText( sz );
}
break;
case IDC_TOGGLE_LINES:
g_bDrawWires = g_SampleUI.GetCheckBox( IDC_TOGGLE_LINES )->GetChecked();
break;
case IDC_PARTITION_INTEGER:
g_iPartitionMode = PARTITION_INTEGER;
break;
case IDC_PARTITION_FRAC_EVEN:
g_iPartitionMode = PARTITION_FRACTIONAL_EVEN;
break;
case IDC_PARTITION_FRAC_ODD:
g_iPartitionMode = PARTITION_FRACTIONAL_ODD;
break;
}
}
示例9: OnChainSelect
//------------------------------------------------------------------------
// Name: OnChainSelect
// Desc: event handler for select one of chains
//------------------------------------------------------------------------
HRESULT OnChainSelect(int iID)
{
if(iID >= 0)
{
wchar_t str[256];
cprimitive* chain = manipulator->cube[iID];
g_SampleUI.SetVisible(true);
swprintf(str,L"You picked chain # %d",iID);
g_SampleUI.GetStatic( IDC_OBJNAME )->SetText(str);
g_SampleUI.GetSlider(IDC_WIDTH_SLIDER)->SetValue(chain->fWidth);
swprintf(str,L"%.2f",chain->fWidth);
g_SampleUI.GetEditBox( IDC_WIDTH )->SetText(str);
g_SampleUI.GetSlider(IDC_LENGTH_SLIDER)->SetValue(chain->fLength);
swprintf(str,L"%.2f",chain->fLength);
g_SampleUI.GetEditBox( IDC_LENGTH )->SetText(str);
swprintf(str,L"%.2f",chain->restrictAngleX.x);
g_SampleUI.GetEditBox( IDC_ANGLE_RESTRICT_XL )->SetText(str);
swprintf(str,L"%.2f",chain->restrictAngleX.y);
g_SampleUI.GetEditBox( IDC_ANGLE_RESTRICT_XU )->SetText(str);
swprintf(str,L"%.2f",chain->restrictAngleY.x);
g_SampleUI.GetEditBox( IDC_ANGLE_RESTRICT_YL )->SetText(str);
swprintf(str,L"%.2f",chain->restrictAngleY.y);
g_SampleUI.GetEditBox( IDC_ANGLE_RESTRICT_YU )->SetText(str);
swprintf(str,L"%.2f",chain->vOffset.x);
g_SampleUI.GetEditBox( IDC_OFFSET_X )->SetText(str);
swprintf(str,L"%.2f",chain->vOffset.y);
g_SampleUI.GetEditBox( IDC_OFFSET_Y )->SetText(str);
swprintf(str,L"%.2f",chain->vOffset.z);
g_SampleUI.GetEditBox( IDC_OFFSET_Z )->SetText(str);
swprintf(str,L"%.2f",chain->fDisplace);
g_SampleUI.GetEditBox( IDC_DISPLACE )->SetText(str);
swprintf(str,L"%.2f",chain->fDirection);
g_SampleUI.GetEditBox( IDC_DIRECTION )->SetText(str);
swprintf(str,L"%.2f",chain->fCoefficient);
g_SampleUI.GetEditBox( IDC_COEFFICIENT )->SetText(str);
swprintf(str,L"%.2f",chain->fMass);
g_SampleUI.GetEditBox( IDC_MASS )->SetText(str);
g_SampleUI.GetCheckBox( IDC_TILT )->SetChecked(chain->bTilt);
g_SampleUI.GetCheckBox( IDC_PRESSURE )->SetChecked(chain->bPressure);
g_SampleUI.GetCheckBox( IDC_LASER )->SetChecked(chain->bLaser);
swprintf(str,L"X: %.2f",chain->vAngle.x);
g_SampleUI.GetStatic( IDC_STATIC7 )->SetText(str);
swprintf(str,L"Y: %.2f",chain->vAngle.y);
g_SampleUI.GetStatic( IDC_STATIC8 )->SetText(str);
}
else
{
g_SampleUI.SetVisible(false);
}
return S_OK;
}
示例10: vTrans
//--------------------------------------------------------------------------------------
void CALLBACK OnD3D10FrameRender(ID3D10Device* pDev10, double fTime, float fElapsedTime, void* pUserContext)
{
HRESULT hr;
g_pCamManager->SyncToCameraUI(g_CameraUI);
//dont delete, used no only here
const DXGI_SURFACE_DESC *pBackBufferSurfaceDesc = DXUTGetDXGIBackBufferSurfaceDesc();
if( ShadowAlgorithm != OldShadowAlgorithm )
{
OldShadowAlgorithm = ShadowAlgorithm;
switch( ShadowAlgorithm )
{
case STANDARD_BP:
g_ABP.OnD3D10DestroyDevice();
break;
case BP_MSSM_KERNEL:
g_BPMSSMKernel.OnD3D10DestroyDevice();
break;
case STD_VSM:
g_StdVSM.OnD3D10DestroyDevice();
break;
case MIP_VSM:
g_MipVSM.OnD3D10DestroyDevice();
break;
case HIR_BP:
g_HBP.OnD3D10DestroyDevice();
break;
case BP_GI:
g_BPGI.OnD3D10DestroyDevice();
break;
case STD_PCSS:
g_PCSS.OnD3D10DestroyDevice();
break;
default:
break;
};
switch( ShadowAlgorithm )
{
case STANDARD_BP:
g_ABP.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_ABP.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
case BP_MSSM_KERNEL:
g_BPMSSMKernel.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_BPMSSMKernel.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
case STD_VSM:
g_StdVSM.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_StdVSM.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
case MIP_VSM:
g_MipVSM.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_MipVSM.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
case HIR_BP:
g_HBP.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_HBP.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
case BP_GI:
g_BPGI.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_BPGI.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
case STD_PCSS:
g_PCSS.OnD3D10CreateDevice(pDev10,pBackBufferSurfaceDesc,pUserContext);
g_PCSS.OnD3D10SwapChainResized(pDev10,NULL,pBackBufferSurfaceDesc,pUserContext );
break;
default:
break;
};
}
//begin light and view pos management
{
static double old_fTime = 0.001;
fTime = old_fTime;
old_fTime += 0.02;
static double oldTime = 0;
static unsigned old_iSta = 0;
static double stop_time = 0;
static double total_stop_time = 0;
double tmp = fTime;
unsigned iSta = g_SampleUI.GetCheckBox(IDC_STATIC)->GetChecked();
if( 0 == old_iSta && 1 == iSta )//turn to be static
{
stop_time = fTime - total_stop_time;
}
if( 1 == iSta )
{
total_stop_time += ( fTime - oldTime );
fTime = stop_time;
}
if( 0 == iSta )
{
fTime -= total_stop_time;
}
old_iSta = iSta;
oldTime = tmp;
}//end light and view pos management
S3UTCamera& g_CameraRef = *(g_pCamManager->ActiveEye());
//.........这里部分代码省略.........
示例11: vecEye
//--------------------------------------------------------------------------------------
// Create any D3D9 resources that will live through a device reset (D3DPOOL_MANAGED)
// and aren't tied to the back buffer size
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D10CreateDevice( ID3D10Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
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 );
#define IDC_WIREFRAME 10
g_SampleUI.GetCheckBox( IDC_WIREFRAME )->SetVisible( false );
V_RETURN( LoadEffect10( pd3dDevice ) );
WCHAR str[MAX_PATH];
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1.bmp" ) );
V_RETURN( g_Terrain.LoadTerrain( str, g_SqrtNumTiles, g_SidesPerTile, g_fWorldScale, g_fHeightScale, 1000, 1.0f,
2.0f ) );
ResetBalls();
// Create a Vertex Decl for the terrain and basic meshes
const D3D10_INPUT_ELEMENT_DESC basiclayout[] =
{
{ "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 },
};
D3D10_PASS_DESC PassDesc;
g_pRenderTerrain->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( basiclayout, sizeof( basiclayout ) / sizeof( basiclayout[0] ),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pBasicDecl10 ) );
// Create a Vertex Decl for the ball
const D3D10_INPUT_ELEMENT_DESC balllayout[] =
{
{ "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 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1 },
};
g_pRenderBall->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( balllayout, sizeof( balllayout ) / sizeof( balllayout[0] ),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pBallDecl10 ) );
// Create a Vertex Decl for the grass
const D3D10_INPUT_ELEMENT_DESC grasslayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 1, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D10_INPUT_PER_INSTANCE_DATA, 1 },
};
g_pRenderGrass->GetPassByIndex( 0 )->GetDesc( &PassDesc );
V_RETURN( pd3dDevice->CreateInputLayout( grasslayout, sizeof( grasslayout ) / sizeof( grasslayout[0] ),
PassDesc.pIAInputSignature,
PassDesc.IAInputSignatureSize, &g_pGrassDecl10 ) );
// Load terrain device objects
V_RETURN( g_Terrain.OnCreateDevice( pd3dDevice ) );
// Load a mesh
g_BallMesh.Create( pd3dDevice, L"PIXWorkshop\\lowpolysphere.sdkmesh" );
g_SkyMesh.Create( pd3dDevice, L"PIXWorkshop\\desertsky.sdkmesh" );
// Create a VB for the stream data
D3D10_BUFFER_DESC BufferDesc;
BufferDesc.ByteWidth = NUM_PLAYERS * sizeof( D3DXVECTOR3 );
BufferDesc.Usage = D3D10_USAGE_DYNAMIC;
BufferDesc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
BufferDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
BufferDesc.MiscFlags = 0;
V_RETURN( pd3dDevice->CreateBuffer( &BufferDesc, NULL, &g_pStreamDataVB10 ) );
// Create a VB for the grass instances
BufferDesc.ByteWidth = g_SqrtNumTiles * g_SqrtNumTiles * sizeof( D3DXVECTOR3 );
V_RETURN( pd3dDevice->CreateBuffer( &BufferDesc, NULL, &g_pGrassDataVB10 ) );
// Load a texture for the mesh
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1.bmp" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pHeightTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1_Norm.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pNormalTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\grass_v3_dark_tex.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pGrassTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Dirt_Diff.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pDirtTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Grass_Diff.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pGroundGrassTexRV, NULL ) );
V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"PIXWorkshop\\Terrain1_Mask.dds" ) );
V_RETURN( D3DX10CreateShaderResourceViewFromFile( pd3dDevice, str, NULL, NULL, &g_pMaskTexRV, NULL ) );
//.........这里部分代码省略.........
示例12: 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:
{
gD3DSettingsDlg.SetActive( !gD3DSettingsDlg.IsActive() );
break;
}
case IDC_TEXT:
case IDC_EXPOSURE:
{
gLog2Exposure = (gSampleUI.GetSlider(IDC_EXPOSURE)->GetValue() / 100.0f - 0.5f) * 33.33333;
WCHAR wstr[MAX_PATH];
swprintf_s(wstr, MAX_PATH,
L"Texture Size: %d x %d\n"
L"logRGB L1: %.2f%%\n"
//L"logRGB RMSE: %.4f\n"
//L"Relative error: %.2f%%\n"
//L"mPSNR: %.2f%%\n"
L"Exposure: %.2f\n"
L"Compression Time: %0.2f ms\n"
L"Compression Rate: %0.2f Mp/s\n",
gTexWidth, gTexHeight,
gError, gLog2Exposure,
gCompTime, gCompRate);
gSampleUI.GetStatic(IDC_TEXT)->SetText(wstr);
break;
}
case IDC_MT:
{
// Shut down all previous threading abilities.
DestroyThreads();
gMultithreaded = gSampleUI.GetCheckBox(IDC_MT)->GetChecked();
if (gMultithreaded)
{
InitWin32Threads();
}
// Recompress the texture.
RecompressTexture();
gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT));
break;
}
case IDC_PROFILE:
{
gCompressionFunc = (CompressionFunc*)gSampleUI.GetComboBox(IDC_PROFILE)->GetSelectedData();
// Recompress the texture.
RecompressTexture();
gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT));
break;
}
case IDC_LOAD_TEXTURE:
{
// Store the current working directory.
TCHAR workingDirectory[MAX_PATH];
GetCurrentDirectory(MAX_PATH, workingDirectory);
// Open a file dialog.
OPENFILENAME openFileName;
WCHAR file[MAX_PATH];
file[0] = 0;
ZeroMemory(&openFileName, sizeof(OPENFILENAME));
openFileName.lStructSize = sizeof(OPENFILENAME);
openFileName.lpstrFile = file;
openFileName.nMaxFile = MAX_PATH;
openFileName.lpstrFilter = L"DDS\0*.dds\0\0";
openFileName.nFilterIndex = 1;
openFileName.lpstrInitialDir = NULL;
openFileName.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&openFileName))
{
//CreateTextures(openFileName.lpstrFile);
SAFE_RELEASE(gUncompressedSRV);
LoadTexture(openFileName.lpstrFile);
}
// Restore the working directory. GetOpenFileName changes the current working directory which causes problems with relative paths to assets.
SetCurrentDirectory(workingDirectory);
RecompressTexture();
gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT));
break;
//.........这里部分代码省略.........
示例13: onGUIEvent
void CALLBACK onGUIEvent(UINT event, int controlId, CDXUTControl* control, void *userContext) {
switch(controlId) {
case IDC_TOGGLE_FULLSCREEN:
DXUTToggleFullScreen();
break;
case IDC_PRESET:
if (event == EVENT_COMBOBOX_SELECTION_CHANGED) {
SMAA::Preset selected;
selected = SMAA::Preset(int(hud.GetComboBox(IDC_PRESET)->GetSelectedData()));
onLostDevice(NULL);
onResetDevice(DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL);
}
break;
case IDC_ANTIALIASING:
if (event == EVENT_CHECKBOX_CHANGED)
timer->reset();
break;
case IDC_PROFILE:
if (event == EVENT_CHECKBOX_CHANGED) {
timer->reset();
timer->setEnabled(hud.GetCheckBox(IDC_PROFILE)->GetChecked());
}
break;
case IDC_THRESHOLD:
if (event == EVENT_SLIDER_VALUE_CHANGED) {
CDXUTSlider *slider = hud.GetSlider(IDC_THRESHOLD);
int min, max;
slider->GetRange(min, max);
float scale = float(slider->GetValue()) / (max - min);
smaa->setThreshold(scale * 0.5f);
wstringstream s;
s << L"Threshold: " << scale * 0.5f;
hud.GetStatic(IDC_THRESHOLD_LABEL)->SetText(s.str().c_str());
}
break;
case IDC_MAX_SEARCH_STEPS:
if (event == EVENT_SLIDER_VALUE_CHANGED) {
CDXUTSlider *slider = hud.GetSlider(IDC_MAX_SEARCH_STEPS);
int min, max;
slider->GetRange(min, max);
float scale = float(slider->GetValue()) / (max - min);
smaa->setMaxSearchSteps(int(round(scale * 98.0f)));
wstringstream s;
s << L"Max Search Steps: " << int(round(scale * 98.0f));
hud.GetStatic(IDC_MAX_SEARCH_STEPS_LABEL)->SetText(s.str().c_str());
}
break;
case IDC_MAX_SEARCH_STEPS_DIAG:
if (event == EVENT_SLIDER_VALUE_CHANGED) {
CDXUTSlider *slider = hud.GetSlider(IDC_MAX_SEARCH_STEPS_DIAG);
int min, max;
slider->GetRange(min, max);
float scale = float(slider->GetValue()) / (max - min);
smaa->setMaxSearchStepsDiag(int(round(scale * 20.0f)));
wstringstream s;
s << L"Max Diag. Search Steps: " << int(round(scale * 20.0f));
hud.GetStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL)->SetText(s.str().c_str());
}
break;
case IDC_CORNER_ROUNDING:
if (event == EVENT_SLIDER_VALUE_CHANGED) {
CDXUTSlider *slider = hud.GetSlider(IDC_CORNER_ROUNDING);
int min, max;
slider->GetRange(min, max);
float scale = float(slider->GetValue()) / (max - min);
smaa->setCornerRounding(scale * 100.0f);
wstringstream s;
s << L"Corner Rounding: " << scale * 100.0f;
hud.GetStatic(IDC_CORNER_ROUNDING_LABEL)->SetText(s.str().c_str());
}
break;
}
}
示例14: 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_SettingsDlg.SetActive(!g_SettingsDlg.IsActive());
break;
}
case IDC_CHANGESCENE:
{
CDXUTComboBox* pComboBox = (CDXUTComboBox*) pControl;
g_CurrentSceneId = pComboBox->GetSelectedIndex();
break;
}
case IDC_BLUR_AO:
{
g_BlurAO = g_HUD.GetCheckBox(nControlID)->GetChecked();
break;
}
case IDC_DEINTERLEAVE:
{
g_UseDeinterleavedTexturing = g_HUD.GetCheckBox(nControlID)->GetChecked();
break;
}
case IDC_RANDOMIZE:
{
g_RandomizeSamples = g_HUD.GetCheckBox(nControlID)->GetChecked();
break;
}
case IDC_RADIUS_SLIDER:
{
g_AOParams.Radius = (float) g_HUD.GetSlider(IDC_RADIUS_SLIDER)->GetValue() * MAX_RADIUS_MULT / 100.0f;
WCHAR sz[100];
StringCchPrintf(sz, 100, UI_RADIUS_MULT L"%0.2f", g_AOParams.Radius);
g_HUD.GetStatic(IDC_RADIUS_STATIC)->SetText(sz);
break;
}
case IDC_BIAS_SLIDER:
{
g_AOParams.Bias = (float) g_HUD.GetSlider(IDC_BIAS_SLIDER)->GetValue() / 1000.f;
WCHAR sz[100];
StringCchPrintf(sz, 100, UI_AO_BIAS L"%g", g_AOParams.Bias);
g_HUD.GetStatic(IDC_BIAS_STATIC)->SetText(sz);
break;
}
case IDC_EXPONENT_SLIDER:
{
g_AOParams.PowerExponent = (float)g_HUD.GetSlider(IDC_EXPONENT_SLIDER)->GetValue() / 100.0f;
WCHAR sz[100];
StringCchPrintf(sz, 100, UI_POW_EXPONENT L"%0.2f", g_AOParams.PowerExponent);
g_HUD.GetStatic(IDC_EXPONENT_STATIC)->SetText(sz);
break;
}
case IDC_BLUR_SHARPNESS_SLIDER:
{
g_AOParams.Blur.Sharpness = (float)g_HUD.GetSlider(IDC_BLUR_SHARPNESS_SLIDER)->GetValue() / 100.0f;
WCHAR sz[100];
StringCchPrintf(sz, 100, UI_BLUR_SHARPNESS L"%0.2f", g_AOParams.Blur.Sharpness);
g_HUD.GetStatic(IDC_BLUR_SHARPNESS_STATIC)->SetText(sz);
break;
}
case IDC_PER_PIXEL_AO:
{
g_AOParams.Output.MSAAMode = GFSDK_SSAO_PER_PIXEL_AO;
break;
}
case IDC_PER_SAMPLE_AO:
{
g_AOParams.Output.MSAAMode = GFSDK_SSAO_PER_SAMPLE_AO;
break;
}
case IDC_1xMSAA:
case IDC_2xMSAA:
case IDC_4xMSAA:
case IDC_8xMSAA:
{
g_RenderTargetsDirty = true;
g_MSAACurrentSettings = nControlID - IDC_1xMSAA;
assert(g_MSAACurrentSettings >= MSAA_MODE_1X);
assert(g_MSAACurrentSettings <= MSAA_MODE_8X);
break;
}
}
}
示例15: 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)
{
PERF_NODE_FUNC();
HRESULT hr;
float *pVertex = NULL;
V(g_pVbFloor->Lock(0, 0, (void**)&pVertex, 0));
//移动地板纹理
for (int i = 0; i < 6; ++i)
{
g_aVertexFloor[i*5+4] += (g_fCurSpeed * fElapsedTime * g_fTimeScale / FLOOR_SIZE * 1.8f);
}
memcpy(pVertex, g_aVertexFloor, sizeof(g_aVertexFloor));
V(g_pVbFloor->Unlock());
D3DXMATRIXA16 mWorldViewProjection;
D3DXMATRIXA16 mWorld;
D3DXMATRIXA16 mView;
D3DXMATRIXA16 mProj;
UINT iPass, cPasses;
// Clear the render target and the zbuffer
V(pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DXCOLOR(0.3f,0.3f,0.6f,0.5f), 1.0f, 0));
// Render the scene
if(SUCCEEDED(pd3dDevice->BeginScene()))
{
// Get the projection & view matrix from the camera class
mProj = reinterpret_cast<const D3DXMATRIXA16&>(g_camera.getProjectionMatrix());
mView = reinterpret_cast<const D3DXMATRIXA16&>(g_camera.getViewMatrix());
pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x00000080);
pd3dDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
if (g_SampleUI.GetCheckBox(IDC_CHECK_WIREFRAME)->GetChecked())
{
pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
}
else
{
pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
}
//地板,采用不同变换
D3DXMATRIXA16 coordMatrix;
memset(&coordMatrix, 0, sizeof(D3DXMATRIXA16));
coordMatrix._11 = 1.0f;
coordMatrix._23 = 1.0f;
coordMatrix._32 = 1.0f;
coordMatrix._44 = 1.0f;
V(g_pEffect->SetMatrix("g_mWorldViewProjection", &(coordMatrix*mView*mProj)));
V(g_pEffect->SetMatrix("g_mWorld", &coordMatrix));
V(pd3dDevice->SetVertexDeclaration(g_pVdFloor));
V(pd3dDevice->SetStreamSource(0, g_pVbFloor, 0, 20));
V(g_pEffect->SetTexture("g_texDiffuse", g_pTexFloor));
V(g_pEffect->SetTechnique("NoLight"));
V(g_pEffect->Begin(&cPasses, 0));
for (iPass = 0; iPass < cPasses; iPass++)
{
V(g_pEffect->BeginPass(iPass));
V(pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2));
V(g_pEffect->EndPass());
}
V(g_pEffect->End());
//角色
if (g_character->isGpuSkinning())
{
V(pd3dDevice->SetVertexDeclaration(g_pVdMeshGpuSkinning));
}
else
{
V(pd3dDevice->SetVertexDeclaration(g_pVdMesh));
}
V(g_pEffect->SetValue("g_vCameraPos", &g_camera.getEyePos(), sizeof(grp::Vector3)));
//g_vLightDir = D3DXVECTOR3(cosf(fTime), sinf(fTime), 0.0f);
V(g_pEffect->SetValue("g_vLightDir", &g_vLightDir, sizeof(D3DXVECTOR3)));
V(g_pEffect->SetBool("g_bDiffuse",
g_SampleUI.GetCheckBox(IDC_CHECK_DIFFUSEMAP)->GetChecked()));
V(g_pEffect->SetBool("g_bGloss",
g_SampleUI.GetCheckBox(IDC_CHECK_GLOSS)->GetChecked()));
if (g_SampleUI.GetCheckBox(IDC_CHECK_NORMALMAP)->GetChecked())
{
if (g_character->isGpuSkinning())
{
V(g_pEffect->SetTechnique("Normalmap_Gpu_Skinning"));
}
//.........这里部分代码省略.........