Blitting to d3d9 backbuffer
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
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?
after im done with all the rendering, i want to be able to blit gui components to the back buffer, before presenting it
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.
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.
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)
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.
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.
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
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
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
);
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement