How to draw background
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?
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:
&pBKG is declared as this:
Then I copied the surface to the back buffer:
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.
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 bufferhr = 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement