I can't really answer this without the context so post some links where this is done.
What I can tell you is that the general formula for viewport transformation as done by OpenGL is given as (taken from wiki)
Here x,y
are the what your picture says xmin, ymin
and width, height
is xmax, ymax
. Now there is no specific reason I can think of why you would wanna do a shift of -0.5
but the viewport allows us to draw to a specific portion of the screen.
For example, in video games you would want to draw the minimap on the lower left corner of the screen, hence you could provide the values
x = 0, y = 0, width = 200, height = 200
This would render a 200x200 minimap in the lower left corner. Your second picture does this but instead it chooses a value of
x = -0.5, y = -0.5, width = nx, height = ny
If you substitute it in the above matrix you'll get
$ \frac{nx}{2} * x_{ndc} - \frac{1}{2} + \frac{nx}{2}$
for the $X$ value. This equals
$ \frac{nx}{2} * x_{ndc} + \frac{nx - 1}{2}$
Which is the same as what is done in the picture you posted. Hope it helped somewhat.
EDIT:- 0.5
offset is commonly used to get to the pixel center. See this image as an example.
Here the pixel 3,5
has the center 3.5, 5.5
. This is the 0.5 offset you are seeing. I was confused at first when you were talking about an offset of negative 0.5.