Is there a way to use something like a union to convert from an int to the 4 bytes that glColor4b accepts? I have been experimenting with things like this to acheive this but have had no success as I don’t know how to make the 4 bytes of an int into the right values.
union {
int c;
byte b[4];
} cdat;
cdat.c = ???;
glColor4bv(cdat.b);
I’m pretty sure you don’t want signed bytes (-128…127), which is what 4b will give you. You want unsigned bytes (0…255), which is glColor4ub*. Also change “byte b[4]” to “ubyte b[4]” or “unsigned char b[4]” or “uint8_t b[4]” (if you #include stdint.h).
Also, why the union? Just poke components into the ubyte array directly. The int member packing isn’t portable anyway, as the byte order of the int depends on the machine (little or big endian).