#endif /* !__GNUC__ */
-
#define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */
#define SAFECDOT 1 /* for paranoids */
}
for (j1 = 0; j1 < 2; j1++) {
for (j2 = 2; j2 < 4; j2++) {
- GLfloat e = 0.0F;
- for (i = 0; i < n_comp; i++) {
- e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]);
- }
- if (e < err) {
- err = e;
- v1 = j1;
- v2 = j2;
- }
+ GLfloat e = 0.0F;
+ for (i = 0; i < n_comp; i++) {
+ e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]);
+ }
+ if (e < err) {
+ err = e;
+ v1 = j1;
+ v2 = j2;
+ }
}
}
for (i = 0; i < n_comp; i++) {
{
GLuint x, y;
const GLubyte *data;
- GLuint *encoded = (GLuint *) dest;
+ GLuint *encoded = (GLuint *)dest;
GLubyte *newSource = NULL;
/* Replicate image if width is not M8 or height is not M4 */
/* lookup table for scaling 5 bit colors up to 8 bits */
-static GLubyte _rgb_scale_5[] = {
+static const GLubyte _rgb_scale_5[] = {
0, 8, 16, 25, 33, 41, 49, 58,
66, 74, 82, 90, 99, 107, 115, 123,
132, 140, 148, 156, 165, 173, 181, 189,
};
/* lookup table for scaling 6 bit colors up to 8 bits */
-static GLubyte _rgb_scale_6[] = {
+static const GLubyte _rgb_scale_6[] = {
0, 4, 8, 12, 16, 20, 24, 28,
32, 36, 40, 45, 49, 53, 57, 61,
65, 69, 73, 77, 81, 85, 89, 93,
static void
-fxt1_decode_1HI (GLubyte *code, GLint t, GLubyte *rgba)
+fxt1_decode_1HI (const GLubyte *code, GLint t, GLubyte *rgba)
{
const GLuint *cc;
t *= 3;
- cc = (GLuint *)(code + t / 8);
+ cc = (const GLuint *)(code + t / 8);
t = (cc[0] >> (t & 7)) & 7;
if (t == 7) {
ZERO_4UBV(rgba);
} else {
- cc = (GLuint *)(code + 12);
+ cc = (const GLuint *)(code + 12);
if (t == 0) {
rgba[BCOMP] = UP5(CC_SEL(cc, 0));
rgba[GCOMP] = UP5(CC_SEL(cc, 5));
static void
-fxt1_decode_1CHROMA (GLubyte *code, GLint t, GLubyte *rgba)
+fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLubyte *rgba)
{
const GLuint *cc;
GLuint kk;
- cc = (GLuint *)code;
+ cc = (const GLuint *)code;
if (t & 16) {
cc++;
t &= 15;
t = (cc[0] >> (t * 2)) & 3;
t *= 15;
- cc = (GLuint *)(code + 8 + t / 8);
+ cc = (const GLuint *)(code + 8 + t / 8);
kk = cc[0] >> (t & 7);
rgba[BCOMP] = UP5(kk);
rgba[GCOMP] = UP5(kk >> 5);
static void
-fxt1_decode_1MIXED (GLubyte *code, GLint t, GLubyte *rgba)
+fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLubyte *rgba)
{
const GLuint *cc;
GLuint col[2][3];
GLint glsb, selb;
- cc = (GLuint *)code;
+ cc = (const GLuint *)code;
if (t & 16) {
t &= 15;
t = (cc[1] >> (t * 2)) & 3;
/* col 2 */
- col[0][BCOMP] = (*(GLuint *)(code + 11)) >> 6;
+ col[0][BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
col[0][GCOMP] = CC_SEL(cc, 99);
col[0][RCOMP] = CC_SEL(cc, 104);
/* col 3 */
static void
-fxt1_decode_1ALPHA (GLubyte *code, GLint t, GLubyte *rgba)
+fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLubyte *rgba)
{
const GLuint *cc;
- cc = (GLuint *)code;
+ cc = (const GLuint *)code;
if (CC_SEL(cc, 124) & 1) {
/* lerp == 1 */
GLuint col0[4];
t &= 15;
t = (cc[1] >> (t * 2)) & 3;
/* col 2 */
- col0[BCOMP] = (*(GLuint *)(code + 11)) >> 6;
+ col0[BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
col0[GCOMP] = CC_SEL(cc, 99);
col0[RCOMP] = CC_SEL(cc, 104);
col0[ACOMP] = CC_SEL(cc, 119);
ZERO_4UBV(rgba);
} else {
GLuint kk;
- cc = (GLuint *)code;
+ cc = (const GLuint *)code;
rgba[ACOMP] = UP5(cc[3] >> (t * 5 + 13));
t *= 15;
- cc = (GLuint *)(code + 8 + t / 8);
+ cc = (const GLuint *)(code + 8 + t / 8);
kk = cc[0] >> (t & 7);
rgba[BCOMP] = UP5(kk);
rgba[GCOMP] = UP5(kk >> 5);
fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
GLint i, GLint j, GLubyte *rgba)
{
- static void (*decode_1[]) (GLubyte *, GLint, GLubyte *) = {
+ static void (*decode_1[]) (const GLubyte *, GLint, GLubyte *) = {
fxt1_decode_1HI, /* cc-high = "00?" */
fxt1_decode_1HI, /* cc-high = "00?" */
fxt1_decode_1CHROMA, /* cc-chroma = "010" */
fxt1_decode_1MIXED /* mixed = "1??" */
};
- GLubyte *code = (GLubyte *)texture +
+ const GLubyte *code = (const GLubyte *)texture +
((j / 4) * (stride / 8) + (i / 8)) * 16;
- GLint mode = CC_SEL((GLuint *)code, 125);
+ GLint mode = CC_SEL(code, 125);
GLint t = i & 7;
if (t & 4) {