Fix Direct3D direct mode window resizing.
Also add proper protection to Cegli's code.