Example
Map normalized device coordinates to screen space, then choose a pixel.
highlighted = computed this step
Step 1 — Set up NDC mapping
Use NDC in the standard square before mapping.
NDC square before viewport mapping
Step 2 — Read the NDC point
Read the NDC point coordinates.
Pndc=(21,3−1)
Step 3 — Map x to screen space
Map x from NDC to screen space.
xs=(21+1)/2⋅7=421
Step 4 — Map y down to screen space
Map y down from NDC to screen space.
ys=(1−3−1)/2⋅5=310
Step 5 — Floor to the pixel
Floor the mapped point to a pixel.
pixel=(3,5)
ndc-to-screen-mapping
This lesson uses NDC values in [-1,1]. The viewport transform maps them to screen space, with y flipped downward for raster rows.