From f48530466578acf2306443a5b165e2cf4f0a4521 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 30 Jan 2003 21:46:57 +0000 Subject: [PATCH] Fix for endianess of colour set up of RGBA values. --- src/osgSim/LightPointDrawable.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/osgSim/LightPointDrawable.h b/src/osgSim/LightPointDrawable.h index ccad6870b..153c36d81 100644 --- a/src/osgSim/LightPointDrawable.h +++ b/src/osgSim/LightPointDrawable.h @@ -50,22 +50,36 @@ class OSGSIM_EXPORT LightPointDrawable : public osg::Drawable void reset(); + inline unsigned long asRGBA(const osg::Vec4& color) const + { +#if defined(__sgi) || defined (__hpux__) + // big endian. + return color.asABGR(); +#elif defined (sun) + // should probably test at runtime for endianess, assume big endian right now. + return color.asABGR(); +#else + // x86 little endian + return color.asRGBA(); +#endif + } + inline void addOpaqueLightPoint(unsigned int pointSize,const osg::Vec3& position,const osg::Vec4& color) { if (pointSize>=_sizedOpaqueLightPointList.size()) _sizedOpaqueLightPointList.resize(pointSize+1); - _sizedOpaqueLightPointList[pointSize].push_back(ColorPosition(color.asRGBA(),position)); + _sizedOpaqueLightPointList[pointSize].push_back(ColorPosition(asRGBA(color),position)); } inline void addAdditiveLightPoint(unsigned int pointSize,const osg::Vec3& position,const osg::Vec4& color) { if (pointSize>=_sizedAdditiveLightPointList.size()) _sizedAdditiveLightPointList.resize(pointSize+1); - _sizedAdditiveLightPointList[pointSize].push_back(ColorPosition(color.asRGBA(),position)); + _sizedAdditiveLightPointList[pointSize].push_back(ColorPosition(asRGBA(color),position)); } inline void addBlendedLightPoint(unsigned int pointSize,const osg::Vec3& position,const osg::Vec4& color) { if (pointSize>=_sizedBlendedLightPointList.size()) _sizedBlendedLightPointList.resize(pointSize+1); - _sizedBlendedLightPointList[pointSize].push_back(ColorPosition(color.asRGBA(),position)); + _sizedBlendedLightPointList[pointSize].push_back(ColorPosition(asRGBA(color),position)); } /** draw LightPoints. */