PDA

View Full Version : Direct3D pixel access



Harry Hunt
23-05-2003, 07:04 PM
Hi there!
I'm having a little problem with Direct3D and hope somebody can help me.
I'm trying to access the individual pixels of Direct3D back buffer (IDirect3D8Surface). It works fine in windowed mode but does not work at all in full screen mode (it even crashes).

Here's what I do:



procedure TDXDirect3DSprites.Lock;
begin
if not Failed(FDirect3D8Device.GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO,
FBackBuffer)) then
begin
if Failed(FBackBuffer.LockRect(FLockRect, nil, 0)) then
Exit;
end
else
HandleError(ED3DLockBackBuffer);
FBackBuffer.GetDesc(FSurfaceDesc);
end;

procedure TDXDirect3DSprites.PutPixel(X, Y: Cardinal; Value: TColor);
var
Surface: pLongWord;
PixelColor: TD3DColor;
I: Integer;
begin
Surface := Pointer(Integer(FLockRect.pBits) +
Integer(FLockRect.Pitch * Y) + (X * 4));
Surface^ := ColorToD3DColor(Value);
end;

procedure TDXDirect3DSprites.Unlock;
begin
FBackBuffer.UnlockRect;
FBackBuffer := nil;
end;



I call Lock then PutPixel then Unlock (of course).

FBackBuffer, FLockRect and FSurfaceDesc are public variables.

I know that this only works with 32 bit pixel format... that's not the problem though. The problem is that it works perfectly in windowed mode and doesn't work in fullscreen mode.

Any help is much appreciated!

WILL
09-06-2003, 05:53 AM
Perhaps trying this inquiry on gamedev.net?

OR even try expertsexchange.com. There are quite a few delphi programmers there, I'm sure.