I dont understand the rendering of an opengl window. So lets say i want my graphics card to draw a scene onto the screen. My opengl window is at location, lets say 50, 50, 100, 100 (x, y , width, height). The GPU knows to draw the scene at this location. This is called the viewport and the GPU gets this viewport information in form of a matrix.
What happens when i move my opengl window from location 50, 50, 100, 100 to location 150, 150, 100, 100. How does the GPU gets this new viewport information while still rendering the scene (maybe it is now in the fragmentshader stage). It will paint the wrong pixels at location 50, 50, 100, 100. Please explain.
My opengl window is at location, lets say 50, 50, 100, 100 (x, y , width, height). The GPU knows to draw the scene at this location.
Does it? You are making assumptions about the specific nature of what the internals of the rendering system, OS, and GPU are doing.
In many composition-based rendering systems, the rendering operation you generate when you perform OpenGL commands renders to a piece of memory, some image data. When you do a swap-buffers call, that image gets copied into the actual screen area that you see. So when you move the window around, all that happens is that the image you render to gets copied into a different location. While the copy is indeed performed by the GPU, the rendering operations you directly caused aren't aware of what location their results will ultimately end up in.
Even in rendering systems where you directly render to display memory, whose to say that what you can set as your "viewport" is not manipulated by the internal OpenGL driver? When you move the window from one location to another, the driver can simply offset your viewport settings, and you will be none the wiser.
Basically, there are many ways for it to happen, and which way gets selected depends entirely on how the OpenGL implementation (and attendant OS/rendering system) chooses to handle screen locations.