Skip to main content
GameDev.net gamedev.net
🔒 Locked

Has AlphaBlend to do with IDirect3DSurface9?

Started by jiangcaiyang Feb 27, 2011 at 2:35 AM 1 replies 2.2k views
Original Post
jiangcaiyang
jiangcaiyang
I am recently build up my own Game engine using DX 9,Now I've switched to render system, and I planned to have two versions, one for 2D and the other for 3D.
For 2D rendering. I wonder that whether AlphaBlend has to do with IDirect3DSurface9? I used the following code:

// ???????
if ( FAILED( g_pDevice->CreateOffscreenPlainSurface(
clientWidth, // ?
clientHeight, // ?
D3DFMT_X8R8G8B8, // D3D??
D3DPOOL_SYSTEMMEM, // ?????
&g_pSurface, // ??????????
NULL/*????*/ ) ) ) return;

// ????????
if ( FAILED( D3DXLoadSurfaceFromFile(
g_pSurface, // ????
NULL, // ?????
NULL, // ????
"?????.png", // ?????
NULL, // ???
D3DX_DEFAULT, // ???
D3DCOLOR_XRGB( 0, 0, 0 ), // ????????
NULL/*?????*/ ) ) ) return;

// ??Alpha??
g_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
g_pDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
g_pDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );


But when comes to rendering, the alphablend doesn't work. It seems that alphablend has not to do with IDirect3DSurface9.

How could I solve the problem?

Hodgman
Hodgman
Enabling the alpha blending render-state will cause the next draw-call to be blended with the back buffer, based on the alpha value outputted by that draw-calls pixel shader or fixed-function texture combiner settings.

What is that surface used for? Is it used as a texture in a draw-call that follows the SetRenderState calls?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.