Copy buffer
Blitz3D Forums/Blitz3D Programming/Copy buffer
| ||
Hi, Is there a way to copy blitz backbuffer memory to another application memory? |
| ||
Sure, but it is not easy. The most straightforward method is saving the backbuffer onto disk, and then loading it from the other application. Else, you could maybe create a stream (tcpstream?) and transfer the data via that.. I never tried that. More direct acces would be finding the D3DDevice of the blitz app, and pass it to the other application. Direct3DDevice7=SystemProperty$("Direct3DDevice7") However, this is not easy, and it has been long since I tried something like that. I was able to access the backbuffer from a .DLL As I remember it, reading from it was quite fast, but writing to it was slow. I only have a small piece of the code for that, written in Delphi. //this function copies the z-buffer to the rendertarget procedure LockZBuffer(lpDevice : IDirect3DDevice7); stdcall; var surf2, surf : IDirectDrawSurface7; caps : TDDSCaps2; begin //get rendertarget lpDevice.GetRenderTarget(surf); surf.GetCaps(caps); caps.dwCaps := DDSCAPS_ZBUFFER; //get z-buffer surf.GetAttachedSurface(caps, surf2); //copy z-buffer to rendertarget surf.BltFast(0, 0, surf2, rect(0,0,799,599), 0); //clear z-buffer lpDevice.Clear(1, r, D3DCLEAR_ZBUFFER, $000000, 0, 0); end; Where 'Rendertarget' is the backbuffer. |
| ||
hmm... When I call the command "backBuffer()" it is suposed to return a memory area where the buffer pixels are stored, right ? Or it returns a memory area that only Blitz "knows to read" ? |
| ||
When I call the command "backBuffer()" it is suposed to return a memory area where the buffer pixels are stored, right ? No, I don't think it is right. As I understand it the BackBuffer (or FrameBuffer as it may also be called) is stored in videoram, and it is not possible to read videoram. This is nothing to do with Blitz3D, or how it reads things, it's simply the way that videocards work. In order to have direct access to a framebuffer, you have to make a copy of it in system memory, which I think is what Warner does above, and it's not terribly fast to copy big chunks of memory around like that. |
| ||
As I remember, You can get the D3DS7 surface using : PeekMemInt(BackBuffer()+12) but If it's for a copy, maybe it could be easier to use the clipboard to store data to share... |