Skip to main content
gamedev.net
🔒 Locked

trouble using offscreen surface

Started by zacharya Oct 11, 2004 at 8:46 AM 1 replies 500+ views
Original Post
zacharya
zacharya
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.
being young is a treasure that can''t be valued
zacharya
zacharya
already did....but still nothing happened and my bitmap still not shown.....
being young is a treasure that can''t be valued

Topic Locked

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

Sign in to reply to this topic.