|You generally do put the initD3D in the WM_CREATE and the cleanD3D in the WM_DESTROY.
The problem is you can't really put the render in the WM_PAINT you need to pump the render over and over.
So they have done a horrible hack to use the message loop to pump the render.
The problem with their hack is they can only have one render window and the render speed is controlled by the message loop.
Do you see the sneaky render_frame(); call in the message loop which is the render pump.
The correct way to do it is create a thread in WM_CREATE to pump the render call .. good old CreateThread()
You can link up WM_WINDOWPOSCHANGED (window size change) and WM_PAINT to the render thread if you want to do things from them to the renderer.
So they are basically trying to dodge having to deal with the complexity of having a render thread because it is targetted at beginners.
It is horrible as the render complexity and time goes up the message response time goes out the window.
MS has a proper threaded samples and there are probably others around
Windows Direct3D Multithreaded Rendering Win32 Sample in C++ for Visual Studio 2012[^]
NVidia also has do's and dont's ... see under do's ... Master Render Thread
DX12 Do's And Don'ts | NVIDIA Developer[^]
In vino veritas
modified 7-Sep-17 13:13pm.