Jump to content
  • Advertisement
Sign in to follow this  
zacharya

trouble using offscreen surface

This topic is 5394 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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 );

}

I've already traced it and I think the problem is on this line

if( D3D_OK != pd3dDevice->StretchRect( pSurface,  NULL, pBackBuffer, NULL, D3DTEXF_NONE ) )

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.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
in the control panel, switch to debug runtime, it will show youmore useful error message.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!