|
|
发表于 2006-4-1 09:14:00
|
显示全部楼层
Re: 请问怎么样才能在另一个3D绦蛑邢允疚淖只蛲计?。?>
//此函数必要在DirectX初始化完成后使用
bmpImage=LoadInterfaceImage("Background.bmp",0);
//载入图片
IDirect3DSurface9* LoadInterfaceImage(LPCTSTR sName,D3DCOLOR ColorKey)
{
IDirect3DSurface9* suf=NULL;
D3DXIMAGE_INFO imageInfo;
int Width=0,Heigth=0;
hResult = D3DXGetImageInfoFromFile(sName, &imageInfo);
if (FAILED (hResult))return NULL;
Width=imageInfo.Width;
Heigth=imageInfo.Height;
hResult = pd3dDevice->CreateOffscreenPlainSurface(Width, Heigth, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &suf, NULL);
if (FAILED(hResult))return NULL;
hResult = D3DXLoadSurfaceFromFile( suf,NULL,NULL,sName,NULL,D3DX_DEFAULT,ColorKey,NULL );
if ( FAILED( hResult ) )
{
MessageBox(NULL,"Load image file error!","error",MB_OK);
}
return suf;
}
//渲染
void render(void)
{
// Check to make sure you have a valid Direct3D device
IDirect3DSurface9* backbuffer = NULL;
if( NULL == pd3dDevice )
return;// Clear the back buffer to a blue color
pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB( 0,0,250 ), 1.0f, 0 );
pd3dDevice->GetBackBuffer( 0,0,D3DBACKBUFFER_TYPE_MONO,&backbuffer );
pd3dDevice->StretchRect( bmpImage,NULL,backbuffer,NULL,D3DTEXF_NONE );
pd3dDevice-> resent( NULL, NULL, NULL, NULL );
}
|
|