Game Development Reference
In-Depth Information
The position of the window is specified by the coordinates of the upper
left-hand pixel (winPos x ,winPos y ). The integers winRes x and winRes y are
the dimensions of the window in pixels. Defining it this way, using the size
of the window rather than the coordinates of the lower right-hand corner,
avoids some sticky issues caused by integer pixel coordinates. We are also
careful to distinguish between the size of the window in pixels, and the
physical size of the window. This distinction will become important in
Section 10.2.2.
With that said, it is important to realize that we do not necessarily have
to be rendering to the screen at all. We could be rendering into a buffer to
be saved into a .TGA file or as a frame in an .AVI, or we may be rendering
into a texture as a subprocess of the “main” render, to produce a shadow
map, or a reflection, or the image on a monitor in the virtual world. For
these reasons, the term render target is often used to refer to the current
destination of rendering output.
10.2.2 Pixel Aspect Ratio
Regardless of whether we are rendering to the screen or an off-screen buffer,
we must know the aspect ratio of the pixels, which is the ratio of a pixel's
height to its width. This ratio is often 1:1—that is, we have “square”
pixels—but this is not always the case! We give some examples below, but
it is common for this assumption to go unquestioned and become the source
of complicated kludges applied in the wrong place, to fix up stretched or
squashed images.
The formula for computing the aspect ratio is
Computing the pixel
aspect ratio
pixPhys x
pixPhys y
= devPhys x
devPhys y
devRes y
devRes x .
(10.2)
The notation pixPhys refers to the physical size of a pixel, and devPhys is
the physical height and width of the device on which the image is displayed.
For both quantities, the individual measurements may be unknown, but
that's OK because the ratio is all we need, and this usually is known. For
example, standard desktop monitors come in all different sizes, but the
viewable area on many older monitors has a ratio of 4:3, meaning it is 33%
wider than it is tall. Another common ratio is 16:9 or wider 7 on high-
definition televisions. The integers devRes x and devRes y are the number
7 Monitor manufacturers must have been overjoyed to find that people perceived a
premium quality to these “widescreen” monitors. Monitor sizes are typically measured
by the diagonal, but costs are more directly tied to number of pixels, which is proportional
to area, not diagonal length. Thus, a 16:9 monitor with the same number of pixels as a
4:3 will have a longer diagonal measurement, which is perceived as a “bigger” monitor.
We're not sure if the proliferation of monitors with even wider aspect ratios is fueled
more by market forces or marketing forces.
 
Search WWH ::




Custom Search