glViewport
doesn't cause any clipping. Normally, all drawing is clipped to the window. Since you have asked OpenGL to draw into a region of your window, you will need to also tell OpenGL to clip coordinates outside this viewport. For that, you will need glScissor
.
In addition, your math is wrong. Your projection matrix is 800 units wide by 600 units tall, centered at (0, 0). This is then mapped to a portion of the window that is 400 pixels wide by 300 pixels tall, in the upper-right corner of the window.
If you draw a line from (-100, -100) to (100, 100), it will extend across only a small part of your viewing frustrum. The frustrum is sized to fit in the viewport.
In the image, the blue box is the window, and the red box represents the viewport. The black line should be the line that you drew.
Hope that helps!