Results 1 to 2 of 2

Thread: Direct3D pixel access

  1. #1

    Direct3D pixel access

    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:

    Code:
    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!
    Ask me about the xcess game development kit

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Direct3D pixel access

    Perhaps trying this inquiry on gamedev.net?

    OR even try expertsexchange.com. There are quite a few delphi programmers there, I'm sure.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •