0

i have a game where I inject a directx dll to grab the image. Thats how I grab the image bits:

void dumb_buffer(LPDIRECT3DDEVICE9 pDevice){

    ret = pDevice->GetRenderTarget(0,&pRenderTarget);
    ret = pRenderTarget->GetDesc(&rtDesc);

    pDevice->CreateOffscreenPlainSurface(rtDesc.Width, rtDesc.Height,rtDesc.Format,   
                                            D3DPOOL_DEFAULT, &pDestTarget, NULL);


    pDevice->GetRenderTargetData(pRenderTarget,pDestTarget);

    if(pDestTarget != NULL){
       pDestTarget->LockRect(&rect,0, D3DLOCK_READONLY);
       bits = (unsigned char*)rect.pBits;
       pDestTarget->UnlockRect();
       pDestTarget->Release();
    }

    pRenderTarget->Release();
}

In the first frame everything works fine and rtDesc looks like this:

rtDesc.Format = D3DFMT_R32F
rtDesc.width = 1920
rtDesc.height = 1200 

In the second frame rtDesc looks now like this:

rtDesc.Format = 1280070990
rtDesc.width = 1
rtDesc.height = 1 

Then the next frame everything is fine again and the next frame it is "1280070990" again.

Any suggestions why its behaving like this? Are there two different renderers?

Also, if i start the injection and framegrabbing with "dumb_buffer(..)" the framerate in the game drops and the game judders.

Here are also two screenshots:

luna-arts.de/others/misc/1.jpg

luna-arts.de/others/misc/2.jpg

It looks like each second frame/run there is beeing created a 1x1 Surface.

The return value of GetRenderTarget(..) and GetDesc(..) is D3D_OK

The Game (VBS2) supports SLI Graphiccards, is it possible that this 1x1 Surface is something like a place holder for the second graphiccard? I'm wokring right now with one graphiccard.

The device is always the same, but the address of renderTarget switches between the two addresses seen in the screenshots. So it looks like there a two renderTargets.

The code with the "if(...)" is working, but the framerate drops and the game judders. Any ideas how i can fix this problem?

In the old version of this Game everything worked fine.

Also as long as I'm in the Menu of the game there is only one renderTarget and everything works fine, but as soon as I start a Level there appears a second renderTarget.

Thanks a Lot

Regards Denis

sayezz
  • 77
  • 5
  • RenderTarget texture can be used to draw a lot of things, like shadow maps, posteffect and so on. Seems like you are retrieving this kind of textures. Probably you better use GetFrontBufferData or GetBackBuffer to make screenshots. – Dave Jan 14 '13 at 16:20
  • GetFrontBufferData is to slow. I tried to use GetBackBuffer, but then i get an black image. "bits" is then 0 :( – sayezz Jan 15 '13 at 16:06
  • Yes, GetFrontBufferData is slow, but it's the only way to to capture an antialiased screen shot (which can be turned on in your game) – Dave Jan 16 '13 at 21:04
  • When using "pDevice->GetFrontBufferData(0,buffer)" my ingame image flickers. Its the same when i use "pDevice->GetRenderTargetData(pRenderTarget,buffer) – sayezz Jan 22 '13 at 13:52

0 Answers0