switch to shell scripts
[convexer.git] / nbvtf / nbvtf.h
index 6be4714ed99a26c0d340898bce37986c9abc4851..aa82cbf6a302823416a011f99a956e89e0f43383 100644 (file)
@@ -59,13 +59,23 @@ extern "C" {
  #define STB_IMAGE_IMPLEMENTATION
 #endif
 
+#define STBI_NO_THREAD_LOCALS
 #include "stb/stb_image.h"
 
 #ifdef USE_LIBRGBCX
+ // #define RGBCX_NO_ALGORITHM
  #include "librgbcx.h"
-#else
+ #define HAS_DXT_COMPRESSOR
+#endif
+
+#if USE_STB_DXT
  #define STB_DXT_IMPLEMENTATION
  #include "stb/stb_dxt.h"
+ #define HAS_DXT_COMPRESSOR
+#endif
+
+#ifndef HAS_DXT_COMPRESSOR
+ #warning No DXT compressor specified! S3 Output will be invalid.
 #endif
 
 #ifdef NBVTF_SHOW_STDERR
@@ -541,9 +551,17 @@ void nbvtf_dxt_block( uint8_t *dest, uint8_t *src, int alpha, int qual )
        {
                rgbcx__encode_bc1( qual, dest, src, 0, 0 );
        }
-#else
+#endif
+
+#if USE_STB_DXT
        stb_compress_dxt_block( dest, src, alpha, STB_DXT_HIGHQUAL );
 #endif
+
+#ifndef HAS_DXT_COMPRESSOR
+
+   for( int i=0; i<alpha? 16: 8; i++ )
+      dest[i] = i%1? 0xff: 0x00;
+#endif
 }
 
 void nbvtf_compress_dxt( uint8_t *src, int w, int h, int alpha, int qual,