Archived

This topic is now archived and is closed to further replies.

vcGamer

How to draw background

Recommended Posts

Hi I try to use XSprite and its methods to draw a BMP or JPG as my game background, but they are rendered above my 3d objects;while I want my 3d models to get rendered above the picture as a background of course. The ._43 component (Z) of matrix in the drawtransform method doesn''t work at all please tell me how to render a picture as a real background?

Share this post


Link to post
Share on other sites
Hi!

Here''s how I did mine. I used a D3D surface, loaded the image to it and copied the background to the back buffer.

example code:


  
//declarations

HRESULT hr;

//create the image surface to hold the back buffer on

pD3DDev->CreateImageSurface( 800, 600, D3DFMT_A8R8G8B8, &pBkg );

//load the bmp file to transfer to the back buffer in the frame function

hr = D3DXLoadSurfaceFromFile( pBkg, 0, 0, sFile, 0, D3DX_DEFAULT, 0, 0 );

//send a fail notice if the operation failed.

if(FAILED(hr))
//operation failed

return E_FAIL;
else
//successful operation

return S_OK;
}


&pBKG is declared as this:

IDirect3DSurface8* pBkg; 


Then I copied the surface to the back buffer:

//copy the background image to the back buffer
hr = pD3DDev->CopyRects( pBkg, NULL, 0, pBackBuffer, NULL );


This may not be the best way, but it works. I don''t know if this is exactly what you are looking for, but I''ve been helped so much from this board, so I thought I''d try to pay it forward.

Good Luck.



Much greatness is achieved thru perseverance and faith.

Share this post


Link to post
Share on other sites