Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

85 Zeilen
3.2 KiB

  1. unit uvkuImageView;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. Vulkan, uvkuBase;
  7. type
  8. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. TvkuImageView = class(TvkuAllocHandle)
  10. private
  11. fHandle: VkImageView;
  12. fDeviceCommands: TVkDeviceCommands;
  13. procedure CreateHandle(const aCreateInfo: TVkImageViewCreateInfo);
  14. public
  15. property Handle: VkImageView read fHandle;
  16. property DeviceCommands: TVkDeviceCommands read fDeviceCommands;
  17. constructor Create(
  18. const aCreateInfo: TVkImageViewCreateInfo;
  19. const aDeviceCommands: TVkDeviceCommands;
  20. const aAllocCallbacks: PVkAllocationCallbacks = nil);
  21. constructor Create(
  22. const aHandle: VkImageView;
  23. const aOwnsHandle: Boolean;
  24. const aDeviceCommands: TVkDeviceCommands;
  25. const aAllocCallbacks: PVkAllocationCallbacks = nil);
  26. destructor Destroy; override;
  27. end;
  28. implementation
  29. uses
  30. uvkuUtils;
  31. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  32. //TvkuImageView//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  33. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  34. procedure TvkuImageView.CreateHandle(const aCreateInfo: TVkImageViewCreateInfo);
  35. var err: TVkResult;
  36. begin
  37. if not Assigned(fDeviceCommands.vkCreateImageView) then
  38. raise TvkuInvalidFuncPtrException.Create('vkCreateImageView');
  39. err := fDeviceCommands.vkCreateImageView(fDeviceCommands.Device, @aCreateInfo, AllocCallbacks, @fHandle);
  40. if (err <> VK_SUCCESS) then
  41. raise TvkuErrorException.Create('unable to create image view', err);
  42. end;
  43. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. constructor TvkuImageView.Create(const aCreateInfo: TVkImageViewCreateInfo; const aDeviceCommands: TVkDeviceCommands;
  45. const aAllocCallbacks: PVkAllocationCallbacks);
  46. begin
  47. inherited Create;
  48. fDeviceCommands := aDeviceCommands;
  49. SetAllocCallbacks(aAllocCallbacks);
  50. CreateHandle(aCreateInfo);
  51. end;
  52. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  53. constructor TvkuImageView.Create(const aHandle: VkImageView; const aOwnsHandle: Boolean;
  54. const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: PVkAllocationCallbacks);
  55. begin
  56. inherited Create;
  57. fHandle := aHandle;
  58. fDeviceCommands := aDeviceCommands;
  59. OwnsHandle := aOwnsHandle;
  60. SetAllocCallbacks(aAllocCallbacks);
  61. end;
  62. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  63. destructor TvkuImageView.Destroy;
  64. begin
  65. if OwnsHandle and (fHandle <> VK_INVALID_NDP_HANDLE) then
  66. fDeviceCommands.vkDestroyImageView(fDeviceCommands.Device, fHandle, AllocCallbacks);
  67. fHandle := VK_INVALID_NDP_HANDLE;
  68. inherited Destroy;
  69. end;
  70. end.