Jump to content
  • Advertisement


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


How to draw background

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

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

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:



//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.

//operation failed

return E_FAIL;
//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

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!