Sign in to follow this  
caesar4

Blitting to d3d9 backbuffer

Recommended Posts

i need to blit an image from IDirect3DSurface9 onto the back buffer of an IDirect3DDevice9, ive tried using GetBackBuffer() to get the back buffer, and StretchRect() to blit onto it; no success plz no references to the textured quads article thx for ur help in advance

Share this post


Link to post
Share on other sites
I'm not sure, but I don't think it's possible. Or at least not unless you lock the buffers and copy the data yourself. What is it that you're trying to do? Maybe there's another way around it?

Share this post


Link to post
Share on other sites
You mean you want to draw 2D images onto the final buffer? You can do this with textures. Is there a reason textures will not work?

Or do you mean like a dynamic in-game GUI interface attached to something in the 3D world? I think this is accomplished with render targets. You set a texture as the render target, render your 2D images onto it, then set it as the texture for the control plane. I've not read anything about it, but I assume it works this way.

Share this post


Link to post
Share on other sites
drawing an image to the final buffer, is much faster the directdraw way, than if using a texture( cuz its gotta be world, projection, and camera transformed, then has to be rasterized)

Share this post


Link to post
Share on other sites
I thought DX9 didn't have directdraw, therefore you can't blit anyway? I'm so used to ID3DXSPRITE which handles everything for me.

If you want to do 2d graphics with DX9 I recommend the ID3DXSPRITE interface. It's fast and easy, what more could you want?

Also, I'm pretty sure there's no blitting in DX9 anyway, you have to use textured quads or ID3DXSPRITE.

Share this post


Link to post
Share on other sites
caesar4,

Vertices dont have to be transformed in order to be rendered. You can use already transformed-lit vertices in order to render 2D rectangles. Look at this article, its DX8 buy easy to move to DX9:
http://www.mvps.org/directx/articles/blit3d.htm

The D3DXSprite library has been updated in order to use batched sprites and it works with TL vertices.

Usually you don't want to Lock the backbuffer as you will stop the video driver. Try to stick to standar techniques

Luck!
Guimo



Share this post


Link to post
Share on other sites
Here is something that might be useful. Or it might crawl like a slug. I've never tried it:
Quote:

IDirect3DDevice9::StretchRect Method

Copy the contents of the source rectangle to the destination rectangle. The source rectangle can be stretched and filtered by the copy. This function is often used to change the aspect ratio of a video stream.

Syntax

HRESULT StretchRect( IDirect3DSurface9 *pSourceSurface,
CONST RECT *pSourceRect,
IDirect3DSurface9 *pDestSurface,
CONST RECT *pDestRect,
D3DTEXTUREFILTERTYPE Filter
);

Share this post


Link to post
Share on other sites
Quote:
Original post by caesar4
drawing an image to the final buffer, is much faster the directdraw way, than if using a texture( cuz its gotta be world, projection, and camera transformed, then has to be rasterized)

Blitting to the backbuffer is the single slowest thing you can do to a D3D app. First, you force the GPU to finish rendering, which may be as much as a frame and a half of data. Next, you need to lock the backbuffer - which means you need a lockable backbuffer - which will slow your entire app down. Next, you need to write to it, unlock it, and then present it. If you're doing alpha blending, you also need to be able to read from it. If thats the case, expect less than 10 frames a second even without rendering anything.

Share this post


Link to post
Share on other sites
In DirectX managed (9.0c)

there is

void SurfaceLoader.FromSurface(
Surface destSurface,
Surface srcSurface,
Filter filter,
int colorKey
);

with "destSurface = device.GetRenderTarget(0)" you can blit very fast onto the back buffer.

Share this post


Link to post
Share on other sites

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