how to get get backbuffer to memory?

Started by
10 comments, last by ET3D 17 years, 11 months ago
Does GetRenderTarget work? GetRenderTarget(index,...) when I set index to 0, does it get backbuffer? if I set 1,what do I get? are there any function to get backbuffer? does GetSurfaceLevel GetRenderTarget both create a new surface? if I call GetRenderTarget ,iS new surface created?
Advertisement
Quote:Original post by derek7
Does GetRenderTarget work? GetRenderTarget(index,...) when I set index to 0, does it get backbuffer? if I set 1,what do I get?
As the name suggests, it gets you the current render target - but only a (pointer) reference to it, not the actual data. You can use it to make defensive copies or to re-use render target data. You need to call GetRenderTargetData() if you want the actual binary data.

The index is for the case where you're using MRTs - "Multiple Render Targets" (look it up in the SDK). Chances are you'll only want to use index 0 and that any other indices will cause errors.

Quote:Original post by derek7
are there any function to get backbuffer?
GetBackBuffer() [grin]

Quote:Original post by derek7
does GetSurfaceLevel GetRenderTarget both create a new surface?

if I call GetRenderTarget ,iS new surface created?
No, but it does increment reference counts (Be careful - these functions are easy ways of generating hard-to-find memory leaks [wink]). The SDK documentation pages will tell you what these functions do, what parameters they require etc...

As a more general tip.. if you're using Visual Studio you can use the "Find In Files" (CTRL+SHIFT+F) tool to search *all* of the SDK samples. Stick in the name of the function and it'll come back with a list of working examples that use it. You should be able to use those to work out how to implement it yourself.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

thanks very much.

but

HRESULT GetRenderTargetData(
IDirect3DSurface9* pRenderTarget,
IDirect3DSurface9* pDestSurface
);


The destination surface must be either an off-screen plain surface or a level of a texture (mipmap or cube texture) created with D3DPOOL_SYSTEMMEM.

The source surface must be a regular render target or a level of a render-target texture (mipmap or cube texture) created with POOL_DEFAULT.


can I not get rendertarget to another surface?
if I get rendertarget to memory, I know it will very slow,how to speed it up?


can I read renderTarget to memory by directly reading pixel with pointer?
someting like surface->lock()

another question
what is different between rendertarget and surface?
I think surface is supperset to rendertarget. a rendertarget must be surface.

[Edited by - derek7 on April 29, 2006 11:51:54 AM]
GetRenderTargetData is the fastest possible way. But it is still slow and that’s the reason why you should not read back data from the GPU as part of your general render strategy.
Quote:Original post by Demirug
GetRenderTargetData is the fastest possible way. But it is still slow and that’s the reason why you should not read back data from the GPU as part of your general render strategy.


if I want to get a list of game screen to memory (harddisk), how to make it as quickly as possible?
Quote:Original post by derek7
if I want to get a list of game screen to memory (harddisk), how to make it as quickly as possible?


By "list of game screen to memory", what do you mean? Just the data for a current texture/surface? If so, you're going to have to Lock/Unlock the surface, which will be quite slow (since it has to copy from GPU to CPU [and back?]), as stated above.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Quote:Original post by deadimp
By "list of game screen to memory", what do you mean? Just the data for a current texture/surface? If so, you're going to have to Lock/Unlock the surface, which will be quite slow (since it has to copy from GPU to CPU [and back?]), as stated above.


What was stated above was to use GetRenderTargetData, which is a lot faster than locking the render target. The slow part will be writing the data to disk.
how to ceate a surface on d3d. I can create a texture by D3DXcreatetexture9
but where is createsurface command ?

I can not find it on google and msdn.
Quote:Original post by derek7
but where is createsurface command ?
IDirect3DDevice9::CreateOffscreenPlainSurface() should do the trick. There are some D3DX functions - but they're for the cases where you've already got source data or an existing surface to start with.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

D3DXCreateTexture(d, 800, 600, 0, 0, D3DFMT_R8G8B8, D3DPOOL_SYSTEMMEM, &textured);

textured->GetSurfaceLevel(0,&destsurface);

D3DSURFACE_DESC desc;
destsurface->GetDesc(&desc);

desc.Height is 1024
desc.Width is 1024

why?? because of 2^n? so it must be 512x512 or 1024x1024?

could I create a 800x800 texture?

This topic is closed to new replies.

Advertisement