Possible Writes for 16-bit color This gives 32*32*32 = 32768 possible indices. Because different configurations have different mappings, it's not guaranteed to work on all computers Write: glColor3ub( ((SelectionIndex) % 32) * 8, ((SelectionIndex>>5) % 32) * 8, ((SelectionIndex>>10) % 32) * 8 ); Read: SelectionIndex = (pRGB[index]/8) + ((pRGB[index+1]/8)<<5) + ((pRGB[index+2]/8)<<10); This next one should be even safer, although I can't guarantee it. But it only gives 16*16*16 = 4096 possible indices per selection: Write: glColor3ub( ((SelectionIndex) % 16) * 16 + 8, ((SelectionIndex>>4) % 16) * 16 + 8, ((SelectionIndex>>8) % 16) * 16 + 8 ); Read: SelectionIndex = (pRGB[index]/16) + ((pRGB[index+1]/16)<<4) + ((pRGB[index+2]/16)<<8);