Since, I presume, you are interested in learning, I'm not going to post an answer that you can just paste into your code, instead I'll explain the components you need:
- You need to convert a float value in the range 0..1 into an integer value 0..255. You do this by multiplying the float value with 255 and storing it in an integer.
- You need to "shuffle" values within an integer. This is done with the
<<
operator, sox << y
shuffles the value ofx
to the left byy
bits. - You need to combine multiple components into one integer value. You do this with the
|
operator. In this case,0xFF | 0xFF0000
would become0xFF00FF
.
The rest is just taking the lego pieces I've described above and putting them together in the right places.