-
December 20th, 2017, 12:13 PM
#1
DirectX 9: how we can draw a transparent image?
see how i create a buffer and a surface and draw it on device:
Code:
HRESULT hResult; d3ddev->Clear(0,NULL, D3DCLEAR_TARGET, dColor, 1.0f, 0);
d3ddev->BeginScene();
//creating a backbuffer surface for get the sprite:
LPDIRECT3DSURFACE9 surface;
LPDIRECT3DSURFACE9 backbuffer;
hResult=d3ddev->GetBackBuffer( 0,0,D3DBACKBUFFER_TYPE_MONO,&backbuffer);
hResult=d3ddev->CreateOffscreenPlainSurface(58,80,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&surface,NULL);
//Getting the sprite:
//hResult=D3DXLoadSurfaceFromResource(surface,NULL,NULL, GetModuleHandle(NULL),MAKEINTRESOURCE(ResourceID),NULL,D3DX_DEFAULT,0,NULL);
hResult= D3DXLoadSurfaceFromFile( surface,NULL,NULL,"C:\\Users\\Cambalinho\\Documents\\CB\\testdx\\Bleu Battle.bmp",NULL,D3DX_DEFAULT,D3DCOLOR_XRGB(255,255,255),NULL );
if ( FAILED( hResult ) ) MessageBox(NULL,"Error","erro",MB_OK);
//Draw the sprite:
RECT imRect={100,50,158,130};//destination rect
d3ddev->StretchRect(surface,NULL,backbuffer,&imRect, D3DTEXF_NONE);
the image is drawed. but not transparent.
the StretchRect() don't care about alpha options or i'm missing something when i create the surface?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|