I need to render a texture with some text added dynamically. Once I have this I must render the result on geometry but I can’t find the way. I tried to use some Text Render Components but they have a bad performance and drop down my fps.
I do this in c++ - if this is usefully you i can paste the code here.
I will be very greatfull! Thanks!
I’d have just dropped a CPP/H file I have but the cpp file got blocked. Fairly simple though in essence.
You’ll need a render target:
UTextureRenderTarget2D* RenderTexture = 0
Which needs to be created in one of your constructors
UTextTexture::UTextTexture(const class FObjectInitializer& PCIP)
RenderTexture = PCIP.CreateDefaultSubobject<UTextureRenderTarget2D>(this, TEXT("RenderTexture"));
It will need to be setup with a height and width
RenderTexture->ClearColor = FLinearColor::Black;
And then you can draw to it
FCanvasTextItem txtItem(FVector2D(0.0f, 0.0f), txt, &rFontToUse, FLinearColor::Black);
FCanvas Canvas(RenderTexture->GameThread_GetRenderTargetResource(), NULL, 0.0f, 0.0f, 0.0f, GMaxRHIFeatureLevel); //UE4.5 GMaxRHIFeatureLevelValue);
Canvas.DrawItem(txtItem, FVector2D(kMarginX, kMarginY));