Sign in to follow this  

background image

This topic is 4204 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'm trying to draw a background image in direct3d8 Basically I want to draw an image and then render the scene ontop of that. Now my problem is that I dont know how to go about accessing the backbuffer and setting indivisual pixels. Rendering a quad is not really an option because the image needs to be on the background pixel exact. And the image is not power of two. -CProgrammer

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hey, to access the back buffer you would call GetBackBuffer like this:


LPDIRECT3DSURFACE8 g_pBackBuffer;
g_pD3DDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_pBackBuffer);



Now you will need to create an image surface and load your bmp file like this:


LPDIRECT3DSURFACE8 g_pBackground;
g_pD3DDevice->CreateImageSurface(imagewidth, imageheight, D3DFMT_X8R8G8B8, &g_pBackground);
D3DXLoadSurfaceFromFile(&g_pBackground, NULL, NULL, "background.bmp", NULL, D3DX_DEFAULT, 0, NULL);



Then to render your image you use CopyRects like this:


g_pD3DDevice->CopyRects(g_pBackground, NULL, 0, g_pBackBuffer, NULL);



You should take a look at each of those functions in detail to see what most of the parameters are. Good luck.

Share this post


Link to post
Share on other sites
Hey, to access the back buffer you would call GetBackBuffer like this:


LPDIRECT3DSURFACE8 g_pBackBuffer;
g_pD3DDevice->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &m_pBackBuffer);





Now you will need to create an image surface and load your bmp file like this:


LPDIRECT3DSURFACE8 g_pBackground;
g_pD3DDevice->CreateImageSurface(imagewidth, imageheight, D3DFMT_X8R8G8B8, &g_pBackground);
D3DXLoadSurfaceFromFile(&g_pBackground, NULL, NULL, "background.bmp", NULL, D3DX_DEFAULT, 0, NULL);





Then to render your image you use CopyRects like this:


g_pD3DDevice->CopyRects(g_pBackground, NULL, 0, g_pBackBuffer, NULL);





You should take a look at each of those functions in detail to see what most of the parameters are. Good luck.

EDIT: Ooops didnt relize i posted twice, sorry.

Share this post


Link to post
Share on other sites
Locking the backbuffer is a BAD idea. You'll utterly kill your frame rate. I'd advise breaking the image into 256x256 tiles (larger if possible) and rendering several quads to the backbuffer.

Share this post


Link to post
Share on other sites

This topic is 4204 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this