• Advertisement
Sign in to follow this  

Could Not Load From BackBuffer using a .bmp file (offscreenPlainSurface)

This topic is 2342 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

Attached is the code I am using to create a Offscreenplainsurface using a bitmap image named as "background.bmp".
I am clearing the screen to the blue screen initially and then obtaining the image from the backbuffer.

After running the program, view filled only with blue color gets rendered and not the bitmap image.
Kindly suggest.

Following is the error that comes up when I enabled debugging using DirectX.

[b]Direct3D9: (ERROR) :Invalid source surface interface specified. StretchRect fails[/b]

I could not find any issue with the code. I am simply returning the "surface" reference into the "bkgrd"; which in turn is being used in:

[b]pd3dDevice->StretchRect(bkgrd,NULL,backbuffer,NULL,D3DTEXF_NONE);[/b]


IDirect3DSurface9* getSurfaceFromBitmap()
{
IDirect3DSurface9* surface=NULL;
HRESULT hResult=pd3dDevice->CreateOffscreenPlainSurface(640,480,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&surface,NULL);
if(FAILED(hResult))
return NULL;

hResult = D3DXLoadSurfaceFromFile(surface,NULL,NULL,"background.bmp",NULL,D3DX_DEFAULT,0,NULL);
if(FAILED(hResult))
return NULL;

return surface;
}

[b]bkgrd = getSurfaceFromBitmap();[/b]


Does resource file has anything to do with this.

Share this post


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

  • Advertisement