D-Type Direct Color Rasterizer defines and utilizes only one structure type:
This structure type contains information about D-Type's memory (off-screen) surfaces.
/* D-Type's memory (off-screen) surface */ typedef struct { DT_SRAST_L w, h; /* Surface's dimensions in pixels */ DT_UBYTE* m; /* Pointer to surface's memory buffer */ DT_SLONG l; /* Length of the buffer in bytes (defines pitch) */ } DT_MDC;
The structure members have the following purpose:
w — width of the memory surface in pixels. This value must be positive.
h — height of the memory surface in pixels. D-Type supports bottom-to-top and top-to-bottom surfaces. A positive h value indicates a bottom-to-top surface; a negative h value indicates a top-to-bottom surface. The value 0 is illegal.
m — pointer to a memory buffer that stores the surface's pixels. Depending on the format of the surface, each pixel in the buffer is represented with 8, 16, 24 or 32 bits (i.e. 1, 2, 3 or 4 bytes per pixel).
l — length of the memory buffer in bytes; must equal pitch * abs(h)
In the above equation, pitch is the distance, in bytes, between two memory addresses in the buffer that represent the beginning of two neighbouring pixel rows. Each pixel row consists of precisely w * bytes per pixel bytes that represent the surface's pixels. Consequently, a valid pitch value must not be less than w * bytes per pixel. A pitch value that is exactly w * bytes per pixel bytes indicates that the pixel rows are contiguous; in other words there are no extra bytes between the neighbouring pixel rows. A pitch value that is larger than w * bytes per pixel bytes indicates that the pixel rows are non contiguous; in other words at the end of each row there are some extra bytes (the number of extra bytes is pitch - w * bytes per pixel). Note that when rendering to the memory surface D-Type never reads or writes these extra bytes.
Although not explicitly specified, pitch is an important value that has a direct impact on how D-Type renders pixels to your memory surface. To obtain the surface's pitch, D-Type divides the length of the memory buffer l by the absolute height of the memory surface h. For this reason, you must ensure that l is divisible by abs(h) and that the result of this division is not less than w * bytes per pixel. If these conditions are not met, your pitch value is not properly defined and D-Type will assume the value w * bytes per pixel instead.