OSDN Git Service

fix BGRA and parameter passing
authorRudolf Polzer <divverent@xonotic.org>
Wed, 13 Jul 2011 15:10:58 +0000 (17:10 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 14 Jul 2011 17:12:25 +0000 (19:12 +0200)
s2tc.cpp
s2tc_libtxc_dxtn.cpp

index 082f7d7..f665081 100644 (file)
--- a/s2tc.cpp
+++ b/s2tc.cpp
@@ -4,6 +4,7 @@
 #include <string.h>
 #include <stdint.h>
 #include <getopt.h>
+#include <algorithm>
 #include "libtxc_dxtn.h"
 #include "s2tc_common.h"
 
@@ -562,6 +563,9 @@ int main(int argc, char **argv)
        }
        pic = LoadTGA_BGRA(picdata, piclen);
 
+       for(int x = 0; x < image_width*image_height; ++x)
+               std::swap(pic[4*x], pic[4*x+2]);
+
        int mipcount = 0;
        while(image_width >= (1 << mipcount) || image_height >= (1 << mipcount))
                ++mipcount;
index 2446846..6b412ad 100644 (file)
@@ -191,7 +191,7 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
                                for (i = 0; i < width; i += 4) {
                                        if (width > i + 3) numxpixels = 4;
                                        else numxpixels = width - i;
-                                       encode_block(blkaddr, srcaddr, width, numxpixels, numypixels, -1);
+                                       encode_block(blkaddr, srcaddr, width, numxpixels, numypixels, nrandom);
                                        srcaddr += 4 * numxpixels;
                                        blkaddr += 8;
                                }
@@ -209,7 +209,7 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
                                for (i = 0; i < width; i += 4) {
                                        if (width > i + 3) numxpixels = 4;
                                        else numxpixels = width - i;
-                                       encode_block(blkaddr, srcaddr, width, numxpixels, numypixels, -1);
+                                       encode_block(blkaddr, srcaddr, width, numxpixels, numypixels, nrandom);
                                        srcaddr += 4 * numxpixels;
                                        blkaddr += 16;
                                }
@@ -227,7 +227,7 @@ void tx_compress_dxtn(GLint srccomps, GLint width, GLint height,
                                for (i = 0; i < width; i += 4) {
                                        if (width > i + 3) numxpixels = 4;
                                        else numxpixels = width - i;
-                                       encode_block(blkaddr, srcaddr, width, numxpixels, numypixels, -1);
+                                       encode_block(blkaddr, srcaddr, width, numxpixels, numypixels, nrandom);
                                        srcaddr += 4 * numxpixels;
                                        blkaddr += 16;
                                }