Getting a hardware pointer/handle to a texture

Hi,

Could you expand on how you can get access the D3D handle.

I’ve been attempting to get access to the ID3DTexture like so, where cameraTarget is a UTextureRenderTarget2D. This compiles fine, but crashes when it’s run.


		if (cameraTarget != NULL) {
			if (cameraTarget->TextureReference.IsInitialized()) {
				UE_LOG(LogTemp, Warning, TEXT("cameraTarget - TextureReference.IsInitialized()"));
				FTextureReference fTexRef = cameraTarget->TextureReference;
				FTextureReferenceRHIRef fTextRefRHIref = fTexRef.TextureReferenceRHI;
				FRHITextureReference *frhiTexRef = fTextRefRHIref.GetReference();
				FRHITexture *frhiTex = frhiTexRef->GetReferencedTexture();
				ID3D11Texture2D *d3d11Tex = (ID3D11Texture2D*) frhiTex->GetNativeResource();
			}
		}

I also get a crash with just fTextRef = cameraTarget->Texture.

Thanks