# HG changeset patch
# User Nicky <sl.nicky.ml@googlemail.com>
# Date 1315857062 -7200
# Branch build
# Node ID fd2c604fd35bfa0106134095a7f97e69026c63df
# Parent  31ed721e0c4b3e33bb4a0ce170b98a896e74eca0
Do not put pointers into the LLColor4U union. That messes everything up when compiling under 64 Bit

diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/llimage/llimage.cpp
--- a/indra/llimage/llimage.cpp	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/llimage/llimage.cpp	Mon Sep 12 21:51:02 2011 +0200
@@ -671,10 +671,10 @@
 	if( 4 == getComponents() )
 	{
 		U32* data = (U32*) getData();
+		U32 mColor = color.asRGBA();
+
 		for( S32 i = 0; i < pixels; i++ )
-		{
-			data[i] = color.mAll;
-		}
+			data[i] = mColor;
 	}
 	else
 	if( 3 == getComponents() )
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/llmath/v4coloru.cpp
--- a/indra/llmath/v4coloru.cpp	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/llmath/v4coloru.cpp	Mon Sep 12 21:51:02 2011 +0200
@@ -118,3 +118,34 @@
 	value->set( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) );
 	return TRUE;
 }
+
+
+U32 LLColor4U::asRGBA() const
+{
+	U32 nRet(0);
+
+	// Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here
+
+	nRet |= mV[3];
+	nRet <<= 8;
+	nRet |= mV[2];
+	nRet <<= 8;
+	nRet |= mV[1];
+	nRet <<= 8;
+	nRet |= mV[0];
+
+	return nRet;
+}
+
+void LLColor4U::fromRGBA( U32 aVal )
+{
+	// Little endian: values are swapped in memory. The original code access the array like a U32, so we need to swap here
+
+	mV[0] = aVal & 0xFF;
+	aVal >>= 8;
+	mV[1] = aVal & 0xFF;
+	aVal >>= 8;
+	mV[2] = aVal & 0xFF;
+	aVal >>= 8;
+	mV[3] = aVal & 0xFF;
+}
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/llmath/v4coloru.h
--- a/indra/llmath/v4coloru.h	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/llmath/v4coloru.h	Mon Sep 12 21:51:02 2011 +0200
@@ -47,13 +47,13 @@
 {
 public:
 
-	union
-	{
+	//	union
+	//	{
 		U8         mV[LENGTHOFCOLOR4U];
-		U32        mAll;
-		LLColor4*  mSources;
-		LLColor4U* mSourcesU;
-	};
+	//		U32        mAll;
+	//		LLColor4*  mSources;
+	//		LLColor4U* mSourcesU;
+	//	};
 
 
 	LLColor4U();						// Initializes LLColor4U to (0, 0, 0, 1)
@@ -83,6 +83,9 @@
 		return ret;
 	}
 
+	U32 asRGBA() const;
+	void fromRGBA( U32 aVal );
+
 	const LLColor4U&	setToBlack();						// zero LLColor4U to (0, 0, 0, 1)
 	const LLColor4U&	setToWhite();						// zero LLColor4U to (0, 0, 0, 1)
 
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/llrender/llrendertarget.cpp
--- a/indra/llrender/llrendertarget.cpp	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/llrender/llrendertarget.cpp	Mon Sep 12 21:51:02 2011 +0200
@@ -51,7 +51,7 @@
 	}
 }
 
-bool LLRenderTarget::sUseFBO = false;
+BOOL LLRenderTarget::sUseFBO = false;
 
 LLRenderTarget::LLRenderTarget() :
 	mResX(0),
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/llrender/llrendertarget.h
--- a/indra/llrender/llrendertarget.h	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/llrender/llrendertarget.h	Mon Sep 12 21:51:02 2011 +0200
@@ -63,7 +63,7 @@
 {
 public:
 	//whether or not to use FBO implementation
-	static bool sUseFBO; 
+	static BOOL sUseFBO; 
 
 	LLRenderTarget();
 	~LLRenderTarget();
@@ -143,9 +143,9 @@
 	std::vector<U32> mTex;
 	U32 mFBO;
 	U32 mDepth;
-	bool mStencil;
-	bool mUseDepth;
-	bool mRenderDepth;
+	BOOL mStencil;
+	BOOL mUseDepth;
+	BOOL mRenderDepth;
 	LLTexUnit::eTextureType mUsage;
 	U32 mSamples;
 	
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/newview/llface.cpp
--- a/indra/newview/llface.cpp	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/newview/llface.cpp	Mon Sep 12 21:51:02 2011 +0200
@@ -1739,7 +1739,7 @@
 		LLVector4a src;
 
 		U32 vec[4];
-		vec[0] = vec[1] = vec[2] = vec[3] = color.mAll;
+		vec[0] = vec[1] = vec[2] = vec[3] = color.asRGBA();
 		
 		src.loadua((F32*) vec);
 
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/newview/llnetmap.cpp
--- a/indra/newview/llnetmap.cpp	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/newview/llnetmap.cpp	Mon Sep 12 21:51:02 2011 +0200
@@ -752,7 +752,7 @@
 				continue;
 			}
 			S32 offset = px + py * image_width;
-			((U32*)datap)[offset] = color.mAll;
+			((U32*)datap)[offset] = color.asRGBA();
 		}
 
 		// top line
@@ -765,7 +765,7 @@
 				continue;
 			}
 			S32 offset = px + py * image_width;
-			((U32*)datap)[offset] = color.mAll;
+			((U32*)datap)[offset] = color.asRGBA();
 		}
 	}
 	else
@@ -787,7 +787,7 @@
 					continue;
 				}
 				S32 offset = p_x + p_y * image_width;
-				((U32*)datap)[offset] = color.mAll;
+				((U32*)datap)[offset] = color.asRGBA();
 			}
 		}
 	}
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/newview/llvosky.cpp
--- a/indra/newview/llvosky.cpp	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/newview/llvosky.cpp	Mon Sep 12 21:51:02 2011 +0200
@@ -287,7 +287,7 @@
 			S32 offset = basic_offset * sComponents;
 			U32* pix = (U32*)(data + offset);
 			LLColor4U temp = LLColor4U(mSkyData[basic_offset]);
-			*pix = temp.mAll;
+			*pix = temp.asRGBA();
 		}
 	}
 	createGLImage(sCurrent);
diff -r 31ed721e0c4b3e33bb4a0ce170b98a896e74eca0 -r fd2c604fd35bfa0106134095a7f97e69026c63df indra/newview/llvosky.h
--- a/indra/newview/llvosky.h	Mon Sep 12 20:55:23 2011 +0200
+++ b/indra/newview/llvosky.h	Mon Sep 12 21:51:02 2011 +0200
@@ -171,7 +171,7 @@
 	{
 		S32 offset = (i * sResolution + j) * sComponents;
 		U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
-		*pix = col.mAll;
+		*pix = col.asRGBA();
 	}
 
 	LLColor4U getPixel(const S32 i, const S32 j)
@@ -179,7 +179,7 @@
 		LLColor4U col;
 		S32 offset = (i * sResolution + j) * sComponents;
 		U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
-		col.mAll = *pix;
+		col.fromRGBA( *pix );
 		return col;
 	}
 
