FViewport::GetWindow override

Hey,

I’m just browsing the UE4 source code (I’ve downloaded the latest from the github), and I don’t understand something. Hope this is the place where I can ask this.

So there is the FViewport class which has a pure virtual GetWindow function. This function is used when creating the actual RHIViewport (Runtime/Engine/Private/UnrealClient.cpp). However there are only 2 implementation of the FViewport class: the FDummyViewport and the FSceneViewport. Both overrides this function with returning a null pointer.

Besides that in the UGameViewportClient class (Runtime/Engine/Private/GameViewportClient.cpp) the GetCursor function uses the GetWindow() and casts it to a Windows-specific HWND.

The actual implementation of the RHIViewport depends on return value of the FViewport::GetWindow(). But I don’t know how it will get a valid value.

Am I missing something?

edit:
I’ve searched it for a long time before I post this question. And I think I’ve just found it:
The SlateRHIRenderer is used to create the viewport where the window handle is available (from the NativeWindow->GetOSWindowHandle()).

So it could work when calling from the slate class. But what happens when calling FViewport::InitRHI()? It creates a new ViewportRHI with a null pointer as a window handle.