ASolusPDaButtonMesh is a StaticMeshActor
I running all code in the Game Thread
FVector2D Dimensions is received from input parameter and you could use 512,512 as a test case
so
FVector2D Dimensions(512,512);
RenderTex is in the .h file as either
UPROPERTY()
UCanvasRenderTarget2D* RenderTex;
or
UPROPERTY()
UTextureRenderTarget2D* RenderTex;
FCanvas* Canvas;
Depending which version of code you are testing, the FCanvas method or the CanvasRenderTarget2D method
#Repro
Repro should be pretty easy, just have this in your .h of a static mesh extending class
UPROPERTY()
UTextureRenderTarget2D* RenderTex;
FCanvas* Canvas;
then cpp:
FVector2D Dimensions(512,512);
RenderTex = CastChecked<UTextureRenderTarget2D>(StaticConstructObject(UTextureRenderTarget2D::StaticClass()));
RenderTex->AddToRoot();
RenderTex->ClearColor = FLinearColor(0,0,0,1); //0.2
RenderTex->bNeedsTwoCopies = false;
RenderTex->bHDR = false;
//Set pixel format to include alpha //try 960 //floatRGBA = additive
RenderTex->InitCustomFormat(Dimensions.X, Dimensions.Y, EPixelFormat::PF_A16B16G16R16 , true); //linear gamma
RenderTex->UpdateResourceImmediate();
//Create New Canvas
Canvas = NULL;
Canvas = new FCanvas((FTextureRenderTarget2DResource*) RenderTex->Resource, NULL, 0,0,0);
Canvas->Clear(RenderTex->ClearColor);
Crash happens on the new FCanvas line
all of this in game thread
Thanks!