| | 54 | int colorFloatToRGBAByte(float f) |
|---|
| | 55 | { |
|---|
| | 56 | // We use lroundf and 255 instead of nextafterf(256, 0) to match CG's rounding |
|---|
| | 57 | return max(0, min(static_cast<int>(lroundf(255.0f * f)), 255)); |
|---|
| | 58 | } |
|---|
| | 59 | |
|---|
| | 60 | RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a) |
|---|
| | 61 | { |
|---|
| | 62 | return colorFloatToRGBAByte(a) << 24 | colorFloatToRGBAByte(r) << 16 | colorFloatToRGBAByte(g) << 8 | colorFloatToRGBAByte(b); |
|---|
| | 63 | } |
|---|
| | 64 | |
|---|
| | 65 | RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha) |
|---|
| | 66 | { |
|---|
| | 67 | RGBA32 rgbOnly = color & 0x00FFFFFF; |
|---|
| | 68 | RGBA32 rgba = rgbOnly | colorFloatToRGBAByte(overrideAlpha) << 24; |
|---|
| | 69 | return rgba; |
|---|
| | 70 | } |
|---|
| | 71 | |
|---|