SFA Project On-line Documentation: PackedGlyph
PackedGlyphs are designed to be a compact, quantized representation of
the multi-valued display elements we call "glyphs". The PackedGlyph structure
defines how large of a space each "display dimension" takes up and stores
values which are ready to be drawn. Currently there are only 16 bit and
8 bit values stored in the packed glyph structure, but the structures size
remains a constant 16 bytes (I was once, many moons ago, told that this
was to optimize OpenGL performance by aligning elements on longword boundaries.).
There was originally an intention of treating this structure as a collection
of bits and having a system configuration file declare how many bits each
field should take. In the interest of time the PackedGlyph was written
as is, with explicit types and field names, but there is nothing prohibiting
future work from going in other directions.
//
// PackedGlyph.H - The Packed Glyph Data Structure
//
//
// 2+2+2+1+1+1+1+1+1 = 12 + 4 = 16bytes
#ifndef SFA_PACKED_GLYPH_H
#define SFA_PACKED_GLYPH_H 1
struct PackedGlyph {
short xpos, ypos, zpos;
char xsize, ysize, zsize, color, alpha, shape;
int free_space;
};
// Qsort comparator for arrays of packed glyphs...
int PackedGlyphComparator(const void *, const void *);
#endif
Constructors
Since PackedGlyph is a struct rather than a class, there are no defined
constructors.
Mutators
Since PackedGlyph is a struct rather than a class, there are no defined
mutators.
Accessors
Since PackedGlyph is a struct rather than a class, there are no defined
accessors (as such) but there is a qsort(3) style comparator designed to
allow sorting of arrays of packed glyphs with qsort. The sorting metric
is currently the product of the size of the glyph in x, y, and z. As per
qsort, the function returns 1 if the glyph on the left is smaller than
the glyph on the right, -1 if it is larger, and 0 if they are the same
size. Note that this means that smaller elements are considered "larger"
by qsort and thus end up farther down the array. This sorts the array in
non-increasing order which should was once appropriate for a drawing order
for SFA.
back to main page