SpoutBPFunctionLibrary.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #pragma once
  2. #if PLATFORM_WINDOWS
  3. #include "AllowWindowsPlatformTypes.h"
  4. #endif
  5. #include "Spout.h"
  6. #include <d3d11.h>
  7. #if PLATFORM_WINDOWS
  8. #include "HideWindowsPlatformTypes.h"
  9. #endif
  10. #include "SpoutBPFunctionLibrary.generated.h"
  11. UENUM(BlueprintType)
  12. enum class ESpoutType : uint8
  13. {
  14. Sender,
  15. Receiver
  16. };
  17. UENUM(BlueprintType)
  18. enum class ESpoutState : uint8
  19. {
  20. ER,
  21. EnoR,
  22. noER,
  23. noEnoR
  24. };
  25. UENUM(BlueprintType)
  26. enum class ESpoutSendTextureFrom : uint8
  27. {
  28. GameViewport,
  29. TextureRenderTarget2D
  30. };
  31. USTRUCT(BlueprintType)
  32. struct FSenderStruct
  33. {
  34. GENERATED_USTRUCT_BODY()
  35. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  36. FName sName;
  37. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  38. bool bIsAlive;
  39. //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  40. ESpoutType spoutType;
  41. //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  42. HANDLE sHandle;
  43. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  44. int32 w;
  45. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  46. int32 h;
  47. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  48. int32 SenderID;
  49. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  50. UTexture2D* TextureColor;
  51. UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Spout Struct")
  52. UMaterialInstanceDynamic* MaterialInstanceColor;
  53. // Pointer to our Texture's resource
  54. FTexture2DResource* Texture2DResource;
  55. // Regions we need to update
  56. FUpdateTextureRegion2D* UpdateRegions;
  57. //Sender
  58. ID3D11Texture2D *activeTextures;
  59. ID3D11Resource * sharedResource;
  60. ID3D11ShaderResourceView * rView;
  61. ID3D11Texture2D* texTemp;
  62. void SetName(FName NewsName)
  63. {
  64. sName = NewsName;
  65. }
  66. void SetSenderID(int32 NewSenderID)
  67. {
  68. SenderID = NewSenderID;
  69. }
  70. void SetHandle(HANDLE NewsHandle)
  71. {
  72. sHandle = NewsHandle;
  73. }
  74. void SetW(int32 NewW)
  75. {
  76. w = NewW;
  77. }
  78. void SetH(int32 NewH)
  79. {
  80. h = NewH;
  81. }
  82. FSenderStruct(){
  83. }
  84. };
  85. UCLASS(ClassGroup = Spout, Blueprintable)
  86. class SPOUTPLUGIN_API USpoutBPFunctionLibrary : public UBlueprintFunctionLibrary
  87. {
  88. GENERATED_BODY()
  89. public:
  90. static bool CreateRegisterSender(FName spoutName, ID3D11Texture2D* baseTexture);
  91. UFUNCTION(BlueprintCallable, Category = "Spout", meta = (AdvancedDisplay = "2"))
  92. static bool SpoutSender(FName spoutName, ESpoutSendTextureFrom sendTextureFrom, UTextureRenderTarget2D* textureRenderTarget2D, float targetGamma = 2.2);
  93. UFUNCTION(BlueprintCallable, Category = "Spout")
  94. static void CloseSender(FName spoutName);
  95. UFUNCTION(BlueprintCallable, Category = "Spout")
  96. static bool SpoutReceiver(const FName spoutName, UMaterialInstanceDynamic*& mat, UTexture2D*& texture);
  97. UFUNCTION(BlueprintCallable, Category = "Spout")
  98. static bool SpoutInfo(TArray<FSenderStruct>& Senders);
  99. UFUNCTION(BlueprintCallable, Category = "Spout")
  100. static bool SpoutInfoFrom(FName spoutName, FSenderStruct& SenderStruct);
  101. UFUNCTION(BlueprintCallable, Category = "Spout")
  102. static int32 SetMaxSenders(int32 max);
  103. UFUNCTION(BlueprintCallable, Category = "Spout")
  104. static void GetMaxSenders(int32& max);
  105. UFUNCTION(BlueprintCallable, Category = "Spout")
  106. static UTextureRenderTarget2D* CreateTextureRenderTarget2D(int32 w=1024, int32 h=768, EPixelFormat pixelFormat= EPixelFormat::PF_B8G8R8A8, bool forceLinearGamma = true );
  107. static bool UpdateRegisteredSpout(FName spoutName, ID3D11Texture2D* baseTexture);
  108. };