Brian Paul <[EMAIL PROTECTED]> writes:
> I found a problem when investigating a failed conformance
> test. The CLAMPED_FLOAT_TO_UBYTE_COLOR macro returns the
> int 0 instead of 255 when the value 1.0 is passed in. Keith?
>
> When comparing the float->ubyte macros with using a simple
> multiply and cast I found the difference in resulting ints to
> differ by as much as 2. This could explain another conformance
> failure. I'll investigate further.
The IEEE version of FLOAT_COLOR_TO_UBYTE_COLOR actually does
RoundToInt(f*256) instead of TruncateToInt(f*255).
If the rounding is OK, you could use this:
#define FLOAT_COLOR_TO_UBYTE_COLOR(b, f) \
do { \
GLfloat tmp; \
b = ((*(GLuint *)&f >= IEEE_ONE) \
? (*(GLint *)&f < 0) ? (GLubyte)0 : (GLubyte)255 \
: (tmp = f*(255.0F/256.0F) + 32768.0F, \
(GLubyte)*(GLuint *)&tmp)); \
} while (0)
Josh