Intel i86W Manual page 183

Table of Contents

Advertisement

PROGRAMMING EXAMPLES
9.13 3-D RENDERING
This series of examples are routines that might be used at the lowest level of a graphics
software system to convert a machine-independent description of a 3-D image into val-
ues for the frame buffer of a color video display. Typically, higher-level graphics routines
represent an object as a set of polygons that together roughly describe the surfaces of the
objects to be displayed. The graphics system maintains a database that describes these
polygons in terms of their colors, properties of reflectance or translucence, and the
locations in 3-D space of their vertices. Due to the roughness of the representation, the
amount of information in the database is considerably less than that which must be
delivered to the video display. A rendering procedure, such as Example 9-21, uses inter-
polation to derive the detailed information needed for each pixel in the graphics frame
buffer. The rendering procedure also performs pixel-by-pixel hidden-surface elimination.
The focus of this series of examples is Example 9-21, which operates on a segment of a
scan line. The segment is bounded by two points of given location and color: from point
(Xl, YO, Zl) with color intensities Redl, Grnl, Blul to point (X2, YO, Z2) with color
intensities Red2, Grn2, Blu2. The points and color intensities are determined by higher-
level graphics software. The points represent the intersection of the scan line with two
edges of the projected image of a polygon. For a given scan line, the rendering proce-
dure is executed once for each polygon that projects onto that scan line. The higher-level
graphics software is responsible for orienting the objects with respect to the viewer, for
making perspective calculations, for scaling, and for determining the amount of light that
falls on each polygon vertex.
The 16-bit pixel format is used, giving ample resolution for color shading: 2
6
intensity
values for red, 2
6
intensity values for green, and 24 intensity values for blue. Example
9-15 shows how to set the pixel size. For hidden-surface elimination, the Z-buffer (or
depth buffer) technique is employed, each Z value having a resolution of 16-bits.
Because the examples presented here use almost all of the registers of the i860 micro-
processor, the registers are given symbolic names, as defined by Example 9-16. In a real
application, it is likely that some of the inputs to the rendering procedure would be
passed in floating-point registers instead of the integer registers employed here. The
register allocation shown in Example 9-16 simplifies the examples by avoiding the need
to use any register for multiple purposes.
II SET PIXEL SIZE TO 16
ld.,
psr,
Ra
andnoth
0x00C0, Ra,
orh
0x0040, Ra,
st.,
Ra,
psr
II Work on psr
Ra
II Clear PS
Ra
II PS
=
16-bit pixels
II
Example 9-15. Setting Pixel Size
9-21

Advertisement

Table of Contents
loading

Table of Contents