|

楼主 |
发表于 2011-2-17 21:38:40
|
显示全部楼层
打开深度缓冲 - d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
- d3dpp.EnableAutoDepthStencil = TRUE;
复制代码- //-----------------------------------------------------------------------------
- // Name: Render()
- // Desc: Draws the scene
- //-----------------------------------------------------------------------------
- void Render()
- {
- D3DXMATRIX matrix;
- D3DXMatrixIdentity(&matrix);
- // Clear the backbuffer to a blue color
- g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
- g_pd3dDevice->SetRenderState(D3DRS_ZENABLE , true);
- RECT rct = {0,0,512,512};
- // Begin the scene
- if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
- {
- if ( SUCCEEDED( g_pSprite->Begin(D3DXSPRITE_ALPHABLEND) ) )
- {
- D3DXMatrixTranslation(&matrix, 0.0f, 0.0f, 0.0f);
- g_pSprite->SetTransform(&matrix);
- g_pSprite->Draw(g_pTexture, &rct, NULL, NULL, 0xffffffff);
- g_pSprite->End();
- }
- if ( SUCCEEDED( g_pSprite2->Begin(D3DXSPRITE_ALPHABLEND) ) )
- {
- D3DXMatrixTranslation(&matrix, 0.0f, 0.0f, 1.0f);
- g_pSprite2->SetTransform(&matrix);
- g_pSprite2->Draw(g_pTexture2, &rct, NULL, NULL, 0xffffffff);
- g_pSprite2->End();
- }
- // End the scene
- g_pd3dDevice->EndScene();
- }
- // Present the backbuffer contents to the display
- g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
- }
复制代码 z大的被覆盖在底下,z小的覆盖别的图。z的范围0.0f~1.0f
我一直没开深度缓冲啊。。。。 |
|