Results 1 to 3 of 3

Thread: About TCustomLockableTexture.Lock

  1. #1

    About TCustomLockableTexture.Lock

    function Lock(out Surface: TPixelSurface): Boolean; overload; inline;
    ---------------------------------------------------------------------------------------------------------------------
    Code:
    procedure TForm1.CacheTexture(const ATexture: TCustomLockableTexture);
    var
      LSurface: TPixelSurface;
    begin
      if not ATexture.Lock(LSurface) then       //The code is optimized off the mobile platform   TPixelSurface is a TObject?
      begin
        ShowMessage('lock failed');
        Exit;
      end else
        ShowMessage('lock success');
      //
      try
         if LSurface = nil then
            ShowMessage('surface is null');
      finally
         ATexture.Unlock;
      end;
    end;
    ----------print----------
    --surface is null
    --lock success
    Last edited by devchenxip; 06-12-2018 at 11:40 AM. Reason: format

  2. #2
    Code:
    procedure TForm1.CacheTexture(const ATexture: TCustomLockableTexture);
    var
      LPixels: TLockedPixels;
    begin
      if not ATexture.Lock(LPixels) then 
      begin
        ShowMessage('lock failed');
        Exit;
      end else
        ShowMessage('lock success');
      //
      try
         if not LPixels.valid then
            ShowMessage('invalid pixels');
      finally
         ATexture.Unlock;
      end;
    end;
    ----------print----------
    --lock success

  3. #3
    Thanks, but can you please explain what is the purpose of above code?

    I suppose you are getting the issue when using Delphi's ARC, right?

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
  •