#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. | |
#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 BYTE_TO_CHAN | ( | b | ) | ((b) < 0 ? 0 : (GLchan) (b)) |
Convert from GLbyte to GLchan.
#define CHAN_TO_FLOAT | ( | c | ) | UBYTE_TO_FLOAT(c) |
Convert from GLchan to GLfloat.
#define CHAN_TO_UBYTE | ( | c | ) | (c) |
Convert from GLchan to GLubyte.
#define CLAMPED_FLOAT_TO_CHAN | ( | c, | |||
f | ) | 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 | ) | ((i) < 0 ? 0 : (GLchan) ((i) >> 23)) |
Convert from GLint to GLchan.
#define PACK_COLOR_1555 | ( | A, | |||
B, | |||||
G, | |||||
R | ) |
Value:
((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \ ((A) ? 0x8000 : 0))
#define PACK_COLOR_1555_REV | ( | A, | |||
B, | |||||
G, | |||||
R | ) |
#define PACK_COLOR_233 | ( | B, | |||
G, | |||||
R | ) | (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5)) |
#define PACK_COLOR_332 | ( | R, | |||
G, | |||||
B | ) | (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6)) |
#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_5551 | ( | R, | |||
G, | |||||
B, | |||||
A | ) |
Value:
((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \ ((A) ? 1 : 0))
#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_88 | ( | L, | |||
A | ) | (((L) << 8) | (A)) |
#define PACK_COLOR_888 | ( | X, | |||
Y, | |||||
Z | ) | (((X) << 16) | ((Y) << 8) | (Z)) |
#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_88_REV | ( | L, | |||
A | ) | (((A) << 8) | (L)) |
#define SHORT_TO_CHAN | ( | s | ) | ((s) < 0 ? 0 : (GLchan) ((s) >> 7)) |
Convert from GLshort to GLchan.
#define UBYTE_TO_CHAN | ( | b | ) | (b) |
Convert from GLubyte to GLchan.
#define UINT_TO_CHAN | ( | i | ) | ((GLchan) ((i) >> 24)) |
Convert from GLuint to GLchan.
#define UNCLAMPED_FLOAT_TO_CHAN | ( | c, | |||
f | ) | UNCLAMPED_FLOAT_TO_UBYTE(c, f) |
Convert from GLfloat to GLchan.
#define UNCLAMPED_FLOAT_TO_RGB_CHAN | ( | dst, | |||
f | ) |
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)
dst | pointer to destination GLchan[3] array. | |
f | pointer to source GLfloat[3] array. |
#define UNCLAMPED_FLOAT_TO_RGBA_CHAN | ( | dst, | |||
f | ) |
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)
dst | pointer to destination GLchan[4] array. | |
f | pointer to source GLfloat[4] array. |
#define USHORT_TO_CHAN | ( | s | ) | ((GLchan) ((s) >> 8)) |
Convert from GLushort to GLchan.