12 uint32_t LittleLong(uint32_t w)
30 fread(h, sizeof(h), 1, stdin);
31 int height = LittleLong(h[3]);
32 int width = LittleLong(h[4]);
33 int fourcc = LittleLong(h[21]);
34 void (*fetch)(GLint srcRowStride, const GLubyte *pixdata, GLint i, GLint j, GLvoid *texel) = NULL;
40 fetch = fetch_2d_texel_rgba_dxt1;
44 fetch = fetch_2d_texel_rgba_dxt3;
48 fetch = fetch_2d_texel_rgba_dxt5;
52 fprintf(stderr, "Only DXT1, DXT3, DXT5 are supported!\n");
65 fwrite(t, 18, 1, stdout);
67 int n = ((width + 3) / 4) * ((height + 3) / 4);
68 unsigned char *buf = (unsigned char *) malloc(n * blocksize);
69 fread(buf, blocksize, n, stdin);
72 for(y = 0; y < height; ++y)
73 for(x = 0; x < width; ++x)
76 fetch(width, buf, x, y, &data);
77 std::swap(data[0], data[2]);
78 fwrite(data, 4, 1, stdout);