usage:
'Width' - a full-screen window width.
'Height' - a full-screen window heght.
example#1:
I want to do make my screen quadratic (adopting to window width and height) which aligned to center:
glViewport((Width-Height)/2,0,Height,Height); // I took 'Height' as minimal value, so I would have it work on displays which it's width is larget than heightresult will look like this:
+-------+--------------+-------+ < my display
|*******|...............|*******|
|*******|.......my...|*******|
|*******|..viewport..|*******|
|*******|...............|*******|
+-------+--------------+-------+
'*' - black pixel.
example#2:
I want to make my screen like film look (let say: 800x320) to get a result like watching a video (with these dimensions) in media player full-screen mode:
float aspectToY = 320.0f/800.0f; int w = Width; int h = int(float(w)*aspectToY); //!!! correct me if this is wrong. glViewport(0, (Height - h) / 2, w, h); // NOTE: this would work if 'height'(ex:320) <= 'width'(ex:800).the result should be like this (for example if my display would be 800x600):
+---------------------------+ << my display
|************************|
+---------------------------+
|.............my...........|
|.........viewport........|
+---------------------------+
|************************|
+---------------------------+
extra information: OpenGL viewport coordinate system (for glViewport setup):
glViewport(x,y,width,height)
---------window top-------
^-height
|
|....+........+
|................\dimensions(width,height)
|....+........+
|......\offset (x,y)
------------------------> -width
---window bottom-----
As you see (in your screen-shots) screen always aligned on left-bottom corner.
Another thing can be happen:
when your display (monitor) first time using these WxH settings sometimes it could do some shift&scale operation which produces strange screen results...
If this was happend, on LCD\LED monitors do: Menu->Settings->Reset:true
Best wishes, FXACE.