# Calculating Window Coordinates -- glViewPort

I was reading OpenGL’s documentation for glViewPort and there was given a formula for how Window Coordinates are calculated in OpenGL.

This is the equation : - x[SUB]window[/SUB] = (x[sub]normalized[/sub] + 1) * (width / 2) + x

I’m a li’l bit confused, what if x[sub]normalized[/sub] = 1.0 ? Will the x[sub]window[/sub] go out of Screen’s Width?

Like:

x[sub]window[/sub] = (1 + 1) * (width / 2) + x;
x[sub]window[/sub] = 2 * (width/2) + x = width + x

(width being the width of the actual resolution of the Screen)

So, doesn’t it go out of the Screen? Somebody please clear this confusion.

No. Unless you set the viewport x position to a non zero value and/or a viewport width larger than the screen.

So, if you define this:

``````
glViewport(0,0,800,600);

``````

with a window with the same size (800x600), then xwindow max value can be width=800, which is perfect.
But if you do something like

``````
glViewport(100,0,800,600);

``````

Then for sure, you’ll exceed the physical window size.

Read this(maybe once again if the documentation you are referring to is the same).

Thank you for clearing the situation. : )