#include <plib/ul.h>
#include "SkyArchive.hpp"
+#include <assert.h>
+
// FIXME: Remove this section whenever plib has it's own endian conversion
// funcrtions for 64-bit data types.
#ifndef ulEndianLittleDouble
}
#endif
-#include <assert.h>
-
struct SkyArchiveEntry
{
SkyArchiveEntry() : type(0), pData(NULL), iDataSize(0) {}
if (pEntry)
{
unsigned short* pData = (unsigned short*)(pEntry->pData);
- *pInt16 = ulEndianLittle16(*pData);
+ *pInt16 = *pData;
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
unsigned int* pData = (unsigned int*)(pEntry->pData);
- *pInt32 = ulEndianLittle32(*pData);
+ *pInt32 = *pData;
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
unsigned short* pData = (unsigned short*)(pEntry->pData);
- *pUInt16 = ulEndianLittle16(*pData);
+ *pUInt16 = *pData;
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
unsigned int* pData = (unsigned int*)(pEntry->pData);
- *pUInt32 = ulEndianLittle32(*pData);
+ *pUInt32 = *pData;
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
float* pData = (float*)(pEntry->pData);
- *pFloat32 = ulEndianLittleFloat(*pData);
+ *pFloat32 = *pData;
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (pEntry)
{
double* pData = (double*)(pEntry->pData);
- *pFloat64 = ulEndianLittleDouble(*pData);
+ *pFloat64 = *pData;
return SKYRESULT_OK;
}
return SKYRESULT_FAIL;
if (!iNumItemsRead)
FAIL_RETURN_MSG(SKYRESULT_FAIL, "Error: SkyArchive::_Load(): failed to read Archive header.");
- unsigned int ui = thisItem.iDataSize;
- thisItem.iDataSize = ulEndianLittle32(ui);
+ _ulEndianSwap(&thisItem.iDataSize);
_pName = new char[::strlen(thisItem.pName)+1];
::strcpy( _pName, thisItem.pName);
if (1 > iNumItemsRead)
FAIL_RETURN_MSG(SKYRESULT_FAIL, "Error: SkyArchive::_Load(): failed to read embedded archive item.");
- unsigned int ui = embeddedItem.iDataSize;
- embeddedItem.iDataSize = ulEndianLittle32(ui);
+ _ulEndianSwap(&embeddedItem.iDataSize);
switch( embeddedItem.type)
//_boundingBox.SetMax(vecCenter + Vec3f(rRadius, rRadius, rRadius));
archive.FindUInt32("CldNumParticles", &iNumParticles);
+ _ulEndianSwap(&iNumParticles);
+
//if (!bLocal)
archive.FindVec3f("CldCenter", &vecCenter);
+ _ulEndianSwap((unsigned int*)&vecCenter.x);
+ _ulEndianSwap((unsigned int*)&vecCenter.y);
+ _ulEndianSwap((unsigned int*)&vecCenter.z);
Vec3f *pParticlePositions = new Vec3f[iNumParticles];
float *pParticleRadii = new float[iNumParticles];
archive.FindData("CldParticlePositions", ANY_TYPE, (void**const)&pParticlePositions, &iNumBytes);
archive.FindData("CldParticleRadii", ANY_TYPE, (void**const)&pParticleRadii, &iNumBytes);
archive.FindData("CldParticleColors", ANY_TYPE, (void**const)&pParticleColors, &iNumBytes);
-
+
for (unsigned int i = 0; i < iNumParticles; ++i)
{
+
+ _ulEndianSwap((unsigned int*)&pParticlePositions[i].x);
+ _ulEndianSwap((unsigned int*)&pParticlePositions[i].y);
+ _ulEndianSwap((unsigned int*)&pParticlePositions[i].z);
+
+ _ulEndianSwap((unsigned int*)&pParticleRadii[i]);
+
+ _ulEndianSwap((unsigned int*)&pParticleColors[i].x);
+ _ulEndianSwap((unsigned int*)&pParticleColors[i].y);
+ _ulEndianSwap((unsigned int*)&pParticleColors[i].z);
+ _ulEndianSwap((unsigned int*)&pParticleColors[i].w);
+
+
SkyCloudParticle *pParticle = new SkyCloudParticle((pParticlePositions[i] + vecCenter) * rScale,
pParticleRadii[i] * rScale,
pParticleColors[i]);
unsigned int iNumFiles;
if (!SKYFAILED(archive.GetInfo("CloudFile", STRING_TYPE, &iNumFiles)))
{
+ _ulEndianSwap(&iNumFiles);
for (unsigned int i = 0; i < iNumFiles; ++i)
{
FAIL_RETURN(archive.FindString("CloudFile", &pFilename, i));
{
unsigned int iNumClouds = 0;
cloudArchive.FindUInt32("CldNumClouds", &iNumClouds);
+ _ulEndianSwap(&iNumClouds);
SkyArchive subArchive;
//iNumClouds = 5; //set this value to reduce cloud field for debugging
glActiveTexturePtr = (glActiveTextureProc)
SGLookupFunction("glActiveTextureARB");
- }
-
- glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &iNumTextureUnits);
- if (iNumTextureUnits > 0)
- s_iNumTextureUnits = iNumTextureUnits;
- else
- s_iNumTextureUnits = 1;
+ glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &iNumTextureUnits);
+ if (iNumTextureUnits > 0)
+ s_iNumTextureUnits = iNumTextureUnits;
+ else
+ s_iNumTextureUnits = 1;
+ } else
+ s_iNumTextureUnits = 1;
}
_pTextureUnitState = new TexState[s_iNumTextureUnits];