Viewport maping issue

I have a problem on understanding how view port work. The view port seems mapping wrong but I can’t understand why.
Everything is just fine until I try to mapping the scene to a specific area on a window by using view port.

Let’s check my source code.

And the results:

Let see on window 3, the scene is seem mapping wrong place.
Actually, it’s location changes when I resize the window.
Could anyone help me?