secondsen 发表于 2011-2-18 23:57:47

D3DXSPRITE透明度的问题

我开了深度缓冲,可以通过Z来调节那张图显示在上面,那张图显示在下面。我想给精灵做一个透明度,思路就是draw(*pTexture,&rect,&D3DVECTOR3(center),&D3DVECTOR3(position),color0xffffffff)最后的这个颜色的参数,我把alpha换成2f让精灵透明。。就是0x2fffffff,也确实图片有透明的感觉的了,但实质还是不透明的啊。。。。 怎么能真正的透明呢?上面的图片是透明的,就能看到下面的图,怎么做呢?

上代码及截图

//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
void Render()
{
    // Clear the backbuffer to a blue color
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

    RECT rct = {0,0,512,512};
    // Begin the scene
    if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
    {
      if ( SUCCEEDED( g_pSprite->Begin(D3DXSPRITE_ALPHABLEND) ) )
      {
            g_pSprite->Draw(g_pTexture, &rct, NULL, &D3DXVECTOR3(100,100,0), 0x2fffffff);
            g_pSprite->End();
      }
      if ( SUCCEEDED( g_pSprite2->Begin(D3DXSPRITE_ALPHABLEND) ) )
      {
            g_pSprite2->Draw(g_pTexture2, &rct, NULL, &D3DXVECTOR3(0,0,1), 0x2fffffff);
            g_pSprite2->End();
      }
      // End the scene
      g_pd3dDevice->EndScene();
    }
    // Present the backbuffer contents to the display
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}


怎么能让他真的透明,能透过上边的图片,看到下边的图片?

secondsen 发表于 2011-2-19 07:46:20

效果看上去像是图片于背景alpha混合,得到不透明的图然后就这样了?

secondsen 发表于 2011-3-3 10:23:03

找到原因了。。。都忘记这里有个帖子了
页: [1]
查看完整版本: D3DXSPRITE透明度的问题