From 569378bdeba31f3ee23770c243d49ce1b2811b1c Mon Sep 17 00:00:00 2001
From: sam <sam>
Date: Thu, 2 Feb 2017 01:57:43 -0800
Subject: [PATCH] REcompiling for windows...

---
 libraries/gpu/src/gpu/Image.cpp          |  6 +--
 libraries/gpu/src/gpu/Image.h            | 67 ++++++++++++------------
 libraries/model/src/model/TextureMap.cpp | 15 ++----
 3 files changed, 40 insertions(+), 48 deletions(-)

diff --git a/libraries/gpu/src/gpu/Image.cpp b/libraries/gpu/src/gpu/Image.cpp
index 5de1008d8f..46486d9436 100644
--- a/libraries/gpu/src/gpu/Image.cpp
+++ b/libraries/gpu/src/gpu/Image.cpp
@@ -15,10 +15,6 @@ namespace image {
     }
     
 template <> void compress(const PB_RGB32& src, CB_BC1& dst) {
-    
-    for (auto& b : dst.bytes) {
-        b = 12;
-    }
 }
 
 template <> void uncompress(const CB_BC1& src, PB_RGB32& dst) {
@@ -27,7 +23,7 @@ template <> void uncompress(const CB_BC1& src, PB_RGB32& dst) {
     auto c0 = bc1.color0.val;
     auto c1 = bc1.color1.val;
     
-    for (int i = 0; i < PB_RGB32::SIZE; ++i) {
+    for (int i = 0; i < PB_RGB32::LENGTH; ++i) {
         //dst.pixels[i] = ;
         auto r = pixel::mix(
                        c0,
diff --git a/libraries/gpu/src/gpu/Image.h b/libraries/gpu/src/gpu/Image.h
index bda16910c4..4457730594 100644
--- a/libraries/gpu/src/gpu/Image.h
+++ b/libraries/gpu/src/gpu/Image.h
@@ -82,40 +82,37 @@ namespace image {
         public:
             using Format = F;
             using Storage = S;
-            
-            union {
-                Storage raw;
-                Format val{ Format() }; // Format last to be initialized by Format's default constructor
-            };
-            
-            Pixel() {};
+
+            Format val { Format() };
+
+            Pixel() : val(Format()) {};
             Pixel(Format v) : val(v) {}
-            Pixel(Storage s) : raw(s) {}
+            Pixel(Storage s) : val(*static_cast<Format> (&s)) {}
+
+            const Storage* storage() const { return static_cast<Storage> (&val); }
         };
 
-        
         template <typename P, int length> class PixelBlock {
         public:
             using Format = typename P::Format;
             using Storage = typename P::Storage;
-            
-            constexpr uint16_t getLength() const { return length; }
-            uint32_t getSize() const { return length * sizeof(P); }
-            
+
+            static const uint16_t LENGTH { length };
+            static const uint32_t SIZE { length * sizeof(P) };
+
             P pixels[length];
-            
+
             PixelBlock() {}
-            
-            
+
             PixelBlock(const P* srcPixels) {
                 setPixels(srcPixels);
             }
-            
+
             void setPixels(const P* srcPixels) {
                 memcpy(pixels, srcPixels, getSize());
             }
-            
-            const Storage* getStorage() const { return static_cast<const Storage*> (&pixels->raw); }
+
+            const Storage* storage() const { return pixels->storage(); }
         };
         
         template <typename P, int tileW, int tileH> class Tile {
@@ -123,12 +120,12 @@ namespace image {
             using Format = typename P::Format;
             using Storage = typename P::Storage;
             using Block = typename PixelBlock<P, tileW * tileH>;
-            
-            constexpr uint16_t getWidth() const { return tileW; }
-            constexpr uint16_t getHeight() const { return tileH; }
-            
+
+            uint16_t getWidth() const { return tileW; }
+            uint16_t getHeight() const { return tileH; }
+
             Block _block;
-            
+
             Tile() {}
             Tile(const P* srcPixels) : _block(srcPixels) {}
             
@@ -162,15 +159,18 @@ namespace image {
         };
     };
     
-    template <typename T> class CompressedBlock {
+    template <typename F, typename S = typename storage<sizeof(F)>::type> class CompressedBlock {
     public:
-        static const uint32_t SIZE { sizeof(T) };
-        union {
-            Byte bytes[SIZE];
-            T bc;
-        };
-        
+        using Format = F;
+        using Storage = S;
+
+        static const uint32_t SIZE { sizeof(F) };
+
+        Format bc;
+
         CompressedBlock() {}
+
+        const Storage* storage() const { return static_cast<Storage> (&bc); }
     };
     
     
@@ -250,9 +250,10 @@ namespace image {
     class Pixmap {
     public:
         using Tile = T;
-        
+        using Block = typename T::Block;
+
         Grid _grid;
-        PixelBlockArray<T::Block> _blocks;
+        PixelBlockArray<Block> _blocks;
         
         void resize(const Grid::Coord2& widthHeight) {
             _grid = Grid(widthHeight, Coord2(Tile::getWidth(), Tile::getHeight()));
diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp
index 215ee367e4..3e2263ffc8 100755
--- a/libraries/model/src/model/TextureMap.cpp
+++ b/libraries/model/src/model/TextureMap.cpp
@@ -265,7 +265,6 @@ gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImag
         image::PixRGB565 pix3;
         
         image::PB_RGB32 pb0;
-        image::CB_BC1 cb;
         image::PB_RGB32 pb1;
         
         auto pix0_s = sizeof(pix0);
@@ -274,15 +273,11 @@ gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImag
         auto pix3_s = sizeof(pix3);
         
         auto pb0_s = sizeof(pb0);
-        auto cb_s = sizeof(cb);
-        
-        auto cb_bytes = pb0.getStorage();
-        image::compress(pb0, cb);
-        image::uncompress(cb, pb1);
-        
-        image::Grid grid;
-        grid.
-        
+
+        image::Pixmap<image::PixRGB32> theMap();
+
+       // theMap(image.width(), image.height(), image.byteCount(), image.constBits());
+
         if (generateMips) {
             ::generateMips(theTexture, image, formatMip);
         }