Hi!
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.
Thanks!
1 Like
I do this in c++ - if this is usefully you i can paste the code here.
JesusS_1
(Jesús Solé)
November 13, 2015, 7:42pm
3
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)
: Super(PCIP)
{
RenderTexture = PCIP.CreateDefaultSubobject<UTextureRenderTarget2D>(this, TEXT("RenderTexture"));
It will need to be setup with a height and width
RenderTexture->ClearColor = FLinearColor::Black;
RenderTexture->InitAutoFormat(iWidth, iHeight);
RenderTexture->UpdateResourceImmediate();
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.Clear(FLinearColor::White);
Canvas.DrawItem(txtItem, FVector2D(kMarginX, kMarginY));
Canvas.Flush_GameThread(true);
where do you put that code ?
what is PCIP ?