a lot of stuff
This commit is contained in:
1 parent
86f54deb01
commit
a3a80dfa16
35 files changed
+407
No files matched your search
@@ -0,0 +1,17 @@
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DemoPlugin : ModuleRules
|
||||
{
|
||||
public DemoPlugin(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"ImageCore"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_MODULE(FDefaultModuleImpl, DemoPlugin)
|
||||
|
||||
//This registers that it is the implementation of DemoPlugin module
|
||||
//that can be loaded by UE
|
||||
|
||||
//Here could be startup scripts or sth
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "DemoRenderBridge.h"
|
||||
|
||||
#include "Engine/TextureRenderTarget2D.h"
|
||||
#include "ImageCore.h"
|
||||
#include "ImageUtils.h"
|
||||
|
||||
bool UDemoRenderBridge::RenderTargetToPng(
|
||||
UTextureRenderTarget2D* RenderTarget,
|
||||
TArray<uint8>& OutPngBytes,
|
||||
FString& OutError)
|
||||
{
|
||||
OutPngBytes.Reset();
|
||||
OutError.Reset();
|
||||
|
||||
if (!IsInGameThread())
|
||||
{
|
||||
OutError = TEXT("Function must be ran on Game Thread");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsValid(RenderTarget))
|
||||
{
|
||||
OutError = TEXT("Render Target reference is invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Faktyczne wywolanie API C++ Unreala: odczyt Render Targetu do FImage.
|
||||
FImage Image;
|
||||
if (!FImageUtils::GetRenderTargetImage(RenderTarget, Image))
|
||||
{
|
||||
OutError = TEXT("Couldnt read Render Target");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Faktyczne wywolanie API C++ Unreala: kompresja FImage do PNG w pamieci.
|
||||
TArray64<uint8> Encoded;
|
||||
if (!FImageUtils::CompressImage(Encoded, TEXT(".png"), Image, 0))
|
||||
{
|
||||
OutError = TEXT("Couldnt encode png");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Encoded.Num() > MAX_int32)
|
||||
{
|
||||
OutError = TEXT("Result too large");
|
||||
return false;
|
||||
}
|
||||
|
||||
OutPngBytes.Append(Encoded.GetData(), static_cast<int32>(Encoded.Num()));
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "DemoRenderBridge.generated.h"
|
||||
|
||||
class UTextureRenderTarget2D;
|
||||
|
||||
/** Funkcje C++ dostepne w Blueprintach i Python API */
|
||||
UCLASS()
|
||||
class DEMOPLUGIN_API UDemoRenderBridge : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
/** Odczytuje Render Target z GPU i zwraca zakodowany PNG w pamieci. */
|
||||
UFUNCTION(BlueprintCallable, Category = "Demo|C++ Bridge")
|
||||
static bool RenderTargetToPng(
|
||||
UTextureRenderTarget2D* RenderTarget,
|
||||
TArray<uint8>& OutPngBytes,
|
||||
FString& OutError);
|
||||
};
|
||||
Reference in new issue
Block a user