Game Development Reference
In-Depth Information
The following diagram illustrates how we could specify the coordinates for a triangle
on a standard iPhone resolution screen (320 x 480 pixels). The top left of the screen is
the origin and has a coordinate position of (0,0) , while the bottom-right corner has a
position of (320,480) .
To render this triangle all we have to do is fill in an array of CIwSVec2 with the
coordinates and submit them to IwGx, as follows:
CIwSVec2* v = new CIwSVec2[3];
v[0].x = 160; v[0].y = 120;
v[1].x = 20; v[1].y = 360;
v[2].x = 300; v[2].y = 360;
IwGxSetVertStreamScreenSpace(v, 3);
The function call, IwGxSetVertStreamScreenSpace , allows us to specify a list of
screen space (that is, pixel) coordinates we want to use for rendering, but we must
also explicitly state how many vertices we are submitting. In the case of our triangle,
this is three.
It is also possible to specify our coordinates using sub-pixel positioning with the
function call IwGxSetVertStreamScreenSpaceSubPixel . It may be getting a bit on
the long side to type, but using sub-pixel positioning does provide the advantage of
smoother movement on screen, as we are no longer limited to only moving things
around the screen in terms of whole pixels.
Using sub-pixel coordinates can also improve the quality of the final rendered image,
as slow moving objects won't appear to jump between pixel positions if we are
rendering using bilinear filtering.
 
Search WWH ::




Custom Search