2.5.0a, multilevel, ao, dxt5, hostage entities & tweaks. #10 done (x4, x8 & FXAA).
[tar-legacy.git] / MCDV / dds.hpp
index d0971a309a3ba908104e8541f0b3537bca622b8f..b5d6383f7e00d33844307b9eede37d5764dd90f8 100644 (file)
@@ -1,3 +1,4 @@
+#pragma once
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h> 
@@ -7,7 +8,6 @@
 
 #define __max(a,b)            (((a) > (b)) ? (a) : (b))
 #define __min(a,b)            (((a) < (b)) ? (a) : (b))
-#pragma once
 
 #pragma pack(push, 1)
 struct DDS_PIXELFORMAT {
@@ -82,6 +82,8 @@ UINT32 SwapEndian(UINT32 val)
 #define DDS_HEADER_PFSIZE 32
 #define DDS_MAGICNUM 0x20534444;
 
+#define DDS_FLIP_VERTICALLY_ON_WRITE
+
 /*
 imageData:     Pointer to image data
 compressedSize: Pointer to final data size
@@ -252,7 +254,9 @@ bool dds_write(uint8_t* imageData, const char* filename, uint32_t w, uint32_t h,
        }
        else
        {
-               output.write((char*)imageData, final_image_size);
+               for (int row = 0; row < h; row++) {
+                       output.write((char*)imageData + (final_image_size - (row * w * 3)), w * 3);
+               }
        }
 
        output.close();