Original Post
I have a problem using offscreen surface. I already follow all the instructions how to make a surface, loading a bitmap to a surface and then copying it to back buffer using StretchRect() fucntion...the problem is.....the bitmap won't show up.... here's my code I've already traced it and I think the problem is on this line it doesn't return D3D_OK value....which is clearly telling me that something is wrong...but I've check everything....the bitmap file is there....and all the parameters are right.... can anyone help me with my problem here? thanks in advance.
bool loadSurface(void)
{
HRESULT hResult;
hResult = pd3dDevice->CreateOffscreenPlainSurface( 640, 480, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pSurface, NULL );
if( FAILED( hResult ) )
return false;
hResult = D3DXLoadSurfaceFromFile( pSurface, NULL, NULL, "zacharya.bmp", NULL, D3DX_DEFAULT, 0, NULL );
if( FAILED( hResult ) )
return false;
return true;
}
void render(void)
{
IDirect3DSurface9* pBackBuffer = NULL;
if( pd3dDevice == NULL )
return;
pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB( 0,0,255 ), 1.0f, 0 );
pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer );
if( D3D_OK != pd3dDevice->StretchRect( pSurface, NULL, pBackBuffer, NULL, D3DTEXF_NONE ) )
MessageBox(NULL,"gagal","error",0);
pd3dDevice->Present( NULL,NULL,NULL,NULL );
}
if( D3D_OK != pd3dDevice->StretchRect( pSurface, NULL, pBackBuffer, NULL, D3DTEXF_NONE ) )