📄 ch17p2_transitionpageant.cpp
字号:
m_fFadeTime = 0.0f;
m_pFont->RestoreDeviceObjects();
m_pFontSmall->RestoreDeviceObjects();
// Setup render states
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
// create original image texture. This must be created as a render target.
if (FAILED(hr = D3DXCreateTextureFromFileEx(m_pd3dDevice, "Ch17p2_Island.png",
0, 0, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT,
0, NULL, NULL, &m_pOrigTexture))) {
return(hr);
}
if (FAILED(hr = D3DXCreateTextureFromFileEx(m_pd3dDevice, "Ch17p2_trippy256.bmp",
0, 0, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT,
0, NULL, NULL, &m_pSecondTexture))) {
return(hr);
}
SAFE_DELETE(m_pTransition);
CSolidFadeTransition *SolidFadeTransition =
new CSolidFadeTransition(m_pd3dDevice, m_pOrigTexture,
D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f));
SolidFadeTransition->SetDuration(5.0f);
m_pTransition = SolidFadeTransition;
m_fFadeTime = 0.0f;
D3DSURFACE_DESC desc;
m_pOrigTexture->GetLevelDesc(0, &desc);
m_iTextureWidth = desc.Width;
m_iTextureHeight = desc.Height;
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: InvalidateDeviceObjects()
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
{
m_pFont->InvalidateDeviceObjects();
m_pFontSmall->InvalidateDeviceObjects();
SAFE_RELEASE( m_pOrigTexture );
SAFE_RELEASE( m_pSecondTexture );
SAFE_DELETE(m_pTransition);
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: DeleteDeviceObjects()
// Desc: Called when the app is exiting, or the device is being changed,
// this function deletes any device dependent objects.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::DeleteDeviceObjects()
{
m_pFont->DeleteDeviceObjects();
m_pFontSmall->DeleteDeviceObjects();
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: FinalCleanup()
// Desc: Called before the app exits, this function gives the app the chance
// to cleanup after itself.
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::FinalCleanup()
{
SAFE_DELETE( m_pFont );
SAFE_DELETE( m_pFontSmall );
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: ConfirmDevice()
// Desc: Called during device intialization, this code checks the device
// for some minimum set of capabilities
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
D3DFORMAT Format )
{
return S_OK;
}
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: Message proc function to handle key and menu input
//-----------------------------------------------------------------------------
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
switch(uMsg) {
case WM_KEYDOWN:
{
switch(toupper(wParam)) {
case '1':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CSolidFadeTransition *SolidFadeTransition =
new CSolidFadeTransition(m_pd3dDevice, m_pOrigTexture,
D3DXCOLOR(1.0f, 0.0f, 0.0f, 1.0f));
SolidFadeTransition->SetDuration(2.0f);
m_pTransition = SolidFadeTransition;
}
break;
case '2':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CDissolveTransition *DissolveTransition =
new CDissolveTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture);
DissolveTransition->SetDuration(2.0f);
m_pTransition = DissolveTransition;
}
break;
case '3':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CWipeTransition *WipeTransition =
new CWipeTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, CWipeTransition::WipeDir::Random);
WipeTransition->SetDuration(5.0f);
m_pTransition = WipeTransition;
}
break;
case '4':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CMeltTransition *MeltTransition =
new CMeltTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 100);
MeltTransition->SetDuration(5.0f); // looks better when it takes longer
m_pTransition = MeltTransition;
}
break;
case '5':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CConstSpeedMeltTransition *ConstSpeedMeltTransition =
new CConstSpeedMeltTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 100);
ConstSpeedMeltTransition->SetDuration(5.0f); // looks better when it takes longer
m_pTransition = ConstSpeedMeltTransition;
}
break;
case '6':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CCrunchTransition *CrunchTransition =
new CCrunchTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 25);
CrunchTransition->SetDuration(5.0f); // looks better when it takes longer
m_pTransition = CrunchTransition;
}
break;
case '7':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CConstSpeedCrunchTransition *ConstSpeedCrunchTransition =
new CConstSpeedCrunchTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 10);
ConstSpeedCrunchTransition->SetDuration(5.0f);
m_pTransition = ConstSpeedCrunchTransition;
}
break;
case '8':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CStaticDissolveTransition *StaticDissolveTransition =
new CStaticDissolveTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 64, 3);
StaticDissolveTransition->SetDuration(5.0f);
m_pTransition = StaticDissolveTransition;
}
break;
case '9':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CTileTransition<CTileTransitionBehavior_Shrink> *TileTransition =
new CTileTransition<CTileTransitionBehavior_Shrink>(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 5, 5);
TileTransition->SetDuration(2.0f);
m_pTransition = TileTransition;
}
break;
case '0':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CTileTransition<CTileTransitionBehavior_TwirlAndShrink> *TileTransition =
new CTileTransition<CTileTransitionBehavior_TwirlAndShrink>(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 5, 5);
TileTransition->SetDuration(2.0f);
m_pTransition = TileTransition;
}
break;
case 'Q':
{
SAFE_DELETE(m_pTransition);
m_fFadeTime = 0.0001f;
CWarpDissolveTransition *WarpDissolveTransition =
new CWarpDissolveTransition(m_pd3dDevice, m_pOrigTexture, m_pSecondTexture, 10, 10);
WarpDissolveTransition->SetDuration(5.0f);
m_pTransition = WarpDissolveTransition;
}
break;
}
}
break;
}
// Pass remaining messages to default handler
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -