Putting together some simple 3d for fun once again.

Made a little cube, put the vertices and indices together, made a couple of array buffers and rendered a cube.

Now usually to make a cube, you’ll need at least 8 vertices and index lists for the triangles or quads for the six sides. A triangle list seemed suitable, so that makes 12 triangles, 36 indices. So here’s the two lists:

GLshort cubeverts[24] = {
-10, -10, -10,
10, -10, -10,
10, 10, -10,
-10, 10, -10,
-10, -10, 10,
10, -10, 10,
10, 10, 10,
-10, 10, 10
};

GLushort cubeinds[36] = {
0, 3, 2, 0, 2, 1,
1, 2, 6, 1, 6, 5,
4, 5, 6, 4, 6, 7,
0, 4, 7, 0, 7, 3,
7, 6, 2, 7, 2, 3,
0, 1, 5, 0, 5, 4
};

The 8 vertices need in total 24 values, 3 coordinates for each corner. Now if the only thing you really need to know is if a value is positive or negative, that sounds like a bit. Just looking at the values, are they positive or negative, here’s a list of the corresponding polarities:

- - - + - - + +
- - + - - - + +
- + + + + - + +

See how they are conveniently in groups of eight? Reading the bit values with MSB on the left, the three 8-bit values are C8, C4 and DE. Ordered in a single integer, little-endian, that is *0xdec4c8.*

Therefore:

GLshort cubeverts[24];
for(int i=0;i<24;i++) cubeverts[i]=((0xdec4c8 & (1 << i))?1:-1);

For the indices, there’s gotta be a way to compress them down too, keeping in mind the CCW/CW order of faces for triangle lists. Maybe later…

*Related*