next up previous contents index
Next: Matrix Calculations Up: 3D-Display Implementation Previous: Drawing the Network

Low Level Drawing Routines

     

The low level drawing routines are located in the modules d3_graph.c, d3_fonts.c d3_point.c, and d3_dither.c.

The following functions only call the corresponding Xlib routines. The justification for these additional routines is, that they simplify porting to other graphic systems, since they are the lowest level of drawing calls.

  The z-buffer is controlled by the routines in module d3_zGraph.c. The z-buffer is organized as a one dimensional array of float. Thereby, clearing the buffer is very fast. The necessary memory is dynamically allocated (and freed) by the operating system. The position is computed explicitly from the size of the buffer.

A polygon is drawn by the function d3_drawPoly. The corresponding Xlib call cannot be used, since the visibility of each polygon point has to be checked. The implementation is derived from the article "Generic Convex Polygon Scan Conversion and Clipping" by Paul Heckbert.

Several routines for labeling the links and units had to be created. This was necessary because the characters must be addressed point by point because of the z-buffering. The routines are listed in the module d3_fonts.c.  

The local functions draw_char and draw_zbuffered_char are used by d3_draw_string to generate a pixel sequence from the ASCII code of a character and the font array.

The creation of grey values is performed with the function dither in module d3_dither.c.



Niels Mache
Wed May 17 11:23:58 MET DST 1995