core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

colormac.h File Reference


Detailed Description

Color-related macros.

#include "imports.h"
#include "config.h"
#include "macros.h"

Defines

#define BYTE_TO_CHAN(b)   ((b) < 0 ? 0 : (GLchan) (b))
 Convert from GLbyte to GLchan.
#define UBYTE_TO_CHAN(b)   (b)
 Convert from GLubyte to GLchan.
#define SHORT_TO_CHAN(s)   ((s) < 0 ? 0 : (GLchan) ((s) >> 7))
 Convert from GLshort to GLchan.
#define USHORT_TO_CHAN(s)   ((GLchan) ((s) >> 8))
 Convert from GLushort to GLchan.
#define INT_TO_CHAN(i)   ((i) < 0 ? 0 : (GLchan) ((i) >> 23))
 Convert from GLint to GLchan.
#define UINT_TO_CHAN(i)   ((GLchan) ((i) >> 24))
 Convert from GLuint to GLchan.
#define CHAN_TO_UBYTE(c)   (c)
 Convert from GLchan to GLubyte.
#define CHAN_TO_FLOAT(c)   UBYTE_TO_FLOAT(c)
 Convert from GLchan to GLfloat.
#define CLAMPED_FLOAT_TO_CHAN(c, f)   CLAMPED_FLOAT_TO_UBYTE(c, f)
 Convert from GLclampf to GLchan.
#define UNCLAMPED_FLOAT_TO_CHAN(c, f)   UNCLAMPED_FLOAT_TO_UBYTE(c, f)
 Convert from GLfloat to GLchan.
#define COPY_CHAN4(DST, SRC)   COPY_4UBV(DST, SRC)
 Copy a GLchan[4] array.
#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f)
 Convert 3 channels at once.
#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f)
 Convert 4 channels at once.
Generic color packing macros. All inputs should be GLubytes.
Todo:
We may move these into texstore.h at some point.


#define PACK_COLOR_8888(X, Y, Z, W)   (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W))
#define PACK_COLOR_8888_REV(X, Y, Z, W)   (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X))
#define PACK_COLOR_888(X, Y, Z)   (((X) << 16) | ((Y) << 8) | (Z))
#define PACK_COLOR_565(X, Y, Z)   ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3))
#define PACK_COLOR_565_REV(X, Y, Z)   (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
#define PACK_COLOR_5551(R, G, B, A)
#define PACK_COLOR_1555(A, B, G, R)
#define PACK_COLOR_1555_REV(A, B, G, R)
#define PACK_COLOR_4444(R, G, B, A)   ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
#define PACK_COLOR_4444_REV(R, G, B, A)   ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4))
#define PACK_COLOR_88(L, A)   (((L) << 8) | (A))
#define PACK_COLOR_88_REV(L, A)   (((A) << 8) | (L))
#define PACK_COLOR_332(R, G, B)   (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
#define PACK_COLOR_233(B, G, R)   (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))


Define Documentation

#define BYTE_TO_CHAN (  )     ((b) < 0 ? 0 : (GLchan) (b))

Convert from GLbyte to GLchan.

#define CHAN_TO_FLOAT (  )     UBYTE_TO_FLOAT(c)

Convert from GLchan to GLfloat.

#define CHAN_TO_UBYTE (  )     (c)

Convert from GLchan to GLubyte.

#define CLAMPED_FLOAT_TO_CHAN ( c,
 )     CLAMPED_FLOAT_TO_UBYTE(c, f)

Convert from GLclampf to GLchan.

#define COPY_CHAN4 ( DST,
SRC   )     COPY_4UBV(DST, SRC)

Copy a GLchan[4] array.

#define INT_TO_CHAN (  )     ((i) < 0 ? 0 : (GLchan) ((i) >> 23))

Convert from GLint to GLchan.

#define PACK_COLOR_1555 ( A,
B,
G,
 ) 

Value:

((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) |      \
    ((A) ? 0x8000 : 0))

#define PACK_COLOR_1555_REV ( A,
B,
G,
 ) 

Value:

((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) |       \
    ((A) ? 0x80 : 0))

#define PACK_COLOR_233 ( B,
G,
 )     (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))

#define PACK_COLOR_332 ( R,
G,
 )     (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))

#define PACK_COLOR_4444 ( R,
G,
B,
 )     ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))

#define PACK_COLOR_4444_REV ( R,
G,
B,
 )     ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4))

#define PACK_COLOR_5551 ( R,
G,
B,
 ) 

Value:

((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) |      \
    ((A) ? 1 : 0))

#define PACK_COLOR_565 ( X,
Y,
 )     ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3))

#define PACK_COLOR_565_REV ( X,
Y,
 )     (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))

#define PACK_COLOR_88 ( L,
 )     (((L) << 8) | (A))

#define PACK_COLOR_888 ( X,
Y,
 )     (((X) << 16) | ((Y) << 8) | (Z))

#define PACK_COLOR_8888 ( X,
Y,
Z,
 )     (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W))

#define PACK_COLOR_8888_REV ( X,
Y,
Z,
 )     (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X))

#define PACK_COLOR_88_REV ( L,
 )     (((A) << 8) | (L))

#define SHORT_TO_CHAN (  )     ((s) < 0 ? 0 : (GLchan) ((s) >> 7))

Convert from GLshort to GLchan.

#define UBYTE_TO_CHAN (  )     (b)

Convert from GLubyte to GLchan.

#define UINT_TO_CHAN (  )     ((GLchan) ((i) >> 24))

Convert from GLuint to GLchan.

#define UNCLAMPED_FLOAT_TO_CHAN ( c,
 )     UNCLAMPED_FLOAT_TO_UBYTE(c, f)

Convert from GLfloat to GLchan.

#define UNCLAMPED_FLOAT_TO_RGB_CHAN ( dst,
 ) 

Value:

do {                                            \
   UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]);       \
   UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]);       \
   UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]);       \
} while (0)
Convert 3 channels at once.

Parameters:
dst pointer to destination GLchan[3] array.
f pointer to source GLfloat[3] array.
See also:
UNCLAMPED_FLOAT_TO_CHAN.

#define UNCLAMPED_FLOAT_TO_RGBA_CHAN ( dst,
 ) 

Value:

do {                                            \
   UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]);       \
   UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]);       \
   UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]);       \
   UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]);       \
} while (0)
Convert 4 channels at once.

Parameters:
dst pointer to destination GLchan[4] array.
f pointer to source GLfloat[4] array.
See also:
UNCLAMPED_FLOAT_TO_CHAN.

#define USHORT_TO_CHAN (  )     ((GLchan) ((s) >> 8))

Convert from GLushort to GLchan.


Generated on Sun Sep 27 06:47:45 2009 for Mesa Main by  doxygen 1.5.4