Fixing bugs related to 64-bit upgrade in materials

pull/949/head
Chris Russ 2016-07-17 09:49:28 +10:00
parent cc16d4a0db
commit 63a4591683
10 changed files with 90 additions and 52 deletions

View File

@ -365,7 +365,7 @@ void Discreet3DSExporter::WriteTexture(const aiMaterial& mat, aiTextureType type
aiTextureMapMode map_mode[2] = { aiTextureMapMode map_mode[2] = {
aiTextureMapMode_Wrap, aiTextureMapMode_Wrap aiTextureMapMode_Wrap, aiTextureMapMode_Wrap
}; };
float blend = 1.0f; ai_real blend = 1.0;
if (mat.GetTexture(type, 0, &path, NULL, NULL, &blend, NULL, map_mode) != AI_SUCCESS || !path.length) { if (mat.GetTexture(type, 0, &path, NULL, NULL, &blend, NULL, map_mode) != AI_SUCCESS || !path.length) {
return; return;
} }
@ -560,6 +560,12 @@ void Discreet3DSExporter::WritePercentChunk(float f) {
writer.PutF4(f); writer.PutF4(f);
} }
// ------------------------------------------------------------------------------------------------
void Discreet3DSExporter::WritePercentChunk(double f) {
ChunkWriter chunk(writer, Discreet3DS::CHUNK_PERCENTD);
writer.PutF8(f);
}
#endif // ASSIMP_BUILD_NO_3DS_EXPORTER #endif // ASSIMP_BUILD_NO_3DS_EXPORTER
#endif // ASSIMP_BUILD_NO_EXPORT #endif // ASSIMP_BUILD_NO_EXPORT

View File

@ -80,6 +80,7 @@ private:
void WriteString(const aiString& s); void WriteString(const aiString& s);
void WriteColor(const aiColor3D& color); void WriteColor(const aiColor3D& color);
void WritePercentChunk(float f); void WritePercentChunk(float f);
void WritePercentChunk(double f);
private: private:

View File

@ -129,6 +129,7 @@ public:
CHUNK_PERCENTW = 0x0030, // int2 percentage CHUNK_PERCENTW = 0x0030, // int2 percentage
CHUNK_PERCENTF = 0x0031, // float4 percentage CHUNK_PERCENTF = 0x0031, // float4 percentage
CHUNK_PERCENTD = 0x0032, // float8 percentage
// ******************************************************************** // ********************************************************************
// Prj master chunk // Prj master chunk

View File

@ -1270,6 +1270,11 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut)
break; break;
case Discreet3DS::CHUNK_PERCENTD:
// Manually parse the blend factor
pcOut->mTextureBlend = stream->GetF8();
break;
case Discreet3DS::CHUNK_PERCENTF: case Discreet3DS::CHUNK_PERCENTF:
// Manually parse the blend factor // Manually parse the blend factor
pcOut->mTextureBlend = stream->GetF4(); pcOut->mTextureBlend = stream->GetF4();

View File

@ -93,7 +93,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
const char* pKey, const char* pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
float* pOut, ai_real* pOut,
unsigned int* pMax) unsigned int* pMax)
{ {
ai_assert (pOut != NULL); ai_assert (pOut != NULL);
@ -105,7 +105,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
return AI_FAILURE; return AI_FAILURE;
} }
// data is given in floats, simply copy it // data is given in floats, convert to ai_real
unsigned int iWrite = 0; unsigned int iWrite = 0;
if( aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) { if( aiPTI_Float == prop->mType || aiPTI_Buffer == prop->mType) {
iWrite = prop->mDataLength / sizeof(float); iWrite = prop->mDataLength / sizeof(float);
@ -113,7 +113,20 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
iWrite = std::min(*pMax,iWrite); ; iWrite = std::min(*pMax,iWrite); ;
} }
for (unsigned int a = 0; a < iWrite;++a) { for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<float> ( reinterpret_cast<float*>(prop->mData)[a] ); pOut[a] = static_cast<ai_real> ( reinterpret_cast<float*>(prop->mData)[a] );
}
if (pMax) {
*pMax = iWrite;
}
}
// data is given in doubles, convert to float
else if( aiPTI_Double == prop->mType) {
iWrite = prop->mDataLength / sizeof(double);
if (pMax) {
iWrite = std::min(*pMax,iWrite); ;
}
for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<ai_real> ( reinterpret_cast<double*>(prop->mData)[a] );
} }
if (pMax) { if (pMax) {
*pMax = iWrite; *pMax = iWrite;
@ -126,7 +139,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
iWrite = std::min(*pMax,iWrite); ; iWrite = std::min(*pMax,iWrite); ;
} }
for (unsigned int a = 0; a < iWrite;++a) { for (unsigned int a = 0; a < iWrite;++a) {
pOut[a] = static_cast<float> ( reinterpret_cast<int32_t*>(prop->mData)[a] ); pOut[a] = static_cast<ai_real> ( reinterpret_cast<int32_t*>(prop->mData)[a] );
} }
if (pMax) { if (pMax) {
*pMax = iWrite; *pMax = iWrite;
@ -141,7 +154,7 @@ aiReturn aiGetMaterialFloatArray(const aiMaterial* pMat,
const char* cur = prop->mData+4; const char* cur = prop->mData+4;
ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]); ai_assert(prop->mDataLength>=5 && !prop->mData[prop->mDataLength-1]);
for (unsigned int a = 0; ;++a) { for (unsigned int a = 0; ;++a) {
cur = fast_atoreal_move<float>(cur,pOut[a]); cur = fast_atoreal_move<ai_real>(cur,pOut[a]);
if(a==iWrite-1) { if(a==iWrite-1) {
break; break;
} }
@ -241,11 +254,11 @@ aiReturn aiGetMaterialColor(const aiMaterial* pMat,
aiColor4D* pOut) aiColor4D* pOut)
{ {
unsigned int iMax = 4; unsigned int iMax = 4;
const aiReturn eRet = aiGetMaterialFloatArray(pMat,pKey,type,index,(float*)pOut,&iMax); const aiReturn eRet = aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax);
// if no alpha channel is defined: set it to 1.0 // if no alpha channel is defined: set it to 1.0
if (3 == iMax) { if (3 == iMax) {
pOut->a = 1.0f; pOut->a = 1.0;
} }
return eRet; return eRet;
@ -260,7 +273,7 @@ aiReturn aiGetMaterialUVTransform(const aiMaterial* pMat,
aiUVTransform* pOut) aiUVTransform* pOut)
{ {
unsigned int iMax = 4; unsigned int iMax = 4;
return aiGetMaterialFloatArray(pMat,pKey,type,index,(float*)pOut,&iMax); return aiGetMaterialFloatArray(pMat,pKey,type,index,(ai_real*)pOut,&iMax);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -326,7 +339,7 @@ aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
C_STRUCT aiString* path, C_STRUCT aiString* path,
aiTextureMapping* _mapping /*= NULL*/, aiTextureMapping* _mapping /*= NULL*/,
unsigned int* uvindex /*= NULL*/, unsigned int* uvindex /*= NULL*/,
float* blend /*= NULL*/, ai_real* blend /*= NULL*/,
aiTextureOp* op /*= NULL*/, aiTextureOp* op /*= NULL*/,
aiTextureMapMode* mapmode /*= NULL*/, aiTextureMapMode* mapmode /*= NULL*/,
unsigned int* flags /*= NULL*/ unsigned int* flags /*= NULL*/

View File

@ -719,7 +719,7 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial)
} }
// make some more specific tests // make some more specific tests
float fTemp; ai_real fTemp;
int iShading; int iShading;
if (AI_SUCCESS == aiGetMaterialInteger( pMaterial,AI_MATKEY_SHADING_MODEL,&iShading)) { if (AI_SUCCESS == aiGetMaterialInteger( pMaterial,AI_MATKEY_SHADING_MODEL,&iShading)) {
switch ((aiShadingMode)iShading) switch ((aiShadingMode)iShading)
@ -741,7 +741,7 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial)
}; };
} }
if (AI_SUCCESS == aiGetMaterialFloat( pMaterial,AI_MATKEY_OPACITY,&fTemp) && (!fTemp || fTemp > 1.01f)) { if (AI_SUCCESS == aiGetMaterialFloat( pMaterial,AI_MATKEY_OPACITY,&fTemp) && (!fTemp || fTemp > 1.01)) {
ReportWarning("Invalid opacity value (must be 0 < opacity < 1.0)"); ReportWarning("Invalid opacity value (must be 0 < opacity < 1.0)");
} }

View File

@ -669,7 +669,7 @@ public:
unsigned int idx, int* pOut, unsigned int* pMax) const; unsigned int idx, int* pOut, unsigned int* pMax) const;
aiReturn Get(const char* pKey,unsigned int type, aiReturn Get(const char* pKey,unsigned int type,
unsigned int idx, float* pOut, unsigned int* pMax) const; unsigned int idx, ai_real* pOut, unsigned int* pMax) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Retrieve a Type value with a specific key /** @brief Retrieve a Type value with a specific key
@ -690,7 +690,7 @@ public:
unsigned int idx, int& pOut) const; unsigned int idx, int& pOut) const;
aiReturn Get(const char* pKey,unsigned int type, aiReturn Get(const char* pKey,unsigned int type,
unsigned int idx, float& pOut) const; unsigned int idx, ai_real& pOut) const;
aiReturn Get(const char* pKey,unsigned int type, aiReturn Get(const char* pKey,unsigned int type,
unsigned int idx, aiString& pOut) const; unsigned int idx, aiString& pOut) const;
@ -747,7 +747,7 @@ public:
C_STRUCT aiString* path, C_STRUCT aiString* path,
aiTextureMapping* mapping = NULL, aiTextureMapping* mapping = NULL,
unsigned int* uvindex = NULL, unsigned int* uvindex = NULL,
float* blend = NULL, ai_real* blend = NULL,
aiTextureOp* op = NULL, aiTextureOp* op = NULL,
aiTextureMapMode* mapmode = NULL) const; aiTextureMapMode* mapmode = NULL) const;
@ -1329,9 +1329,9 @@ extern "C" {
* structure or NULL if the key has not been found. */ * structure or NULL if the key has not been found. */
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
ASSIMP_API C_ENUM aiReturn aiGetMaterialProperty( ASSIMP_API C_ENUM aiReturn aiGetMaterialProperty(
const C_STRUCT aiMaterial* pMat, const C_STRUCT aiMaterial* pMat,
const char* pKey, const char* pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
const C_STRUCT aiMaterialProperty** pPropOut); const C_STRUCT aiMaterialProperty** pPropOut);
@ -1366,7 +1366,7 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialFloatArray(
const char* pKey, const char* pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
float* pOut, ai_real* pOut,
unsigned int* pMax); unsigned int* pMax);
@ -1395,7 +1395,7 @@ inline aiReturn aiGetMaterialFloat(const aiMaterial* pMat,
const char* pKey, const char* pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
float* pOut) ai_real* pOut)
{ {
return aiGetMaterialFloatArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0); return aiGetMaterialFloatArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0);
} }
@ -1432,7 +1432,7 @@ ASSIMP_API C_ENUM aiReturn aiGetMaterialIntegerArray(const C_STRUCT aiMaterial*
inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial* pMat, inline aiReturn aiGetMaterialInteger(const C_STRUCT aiMaterial* pMat,
const char* pKey, const char* pKey,
unsigned int type, unsigned int type,
unsigned int index, unsigned int index,
int* pOut) int* pOut)
{ {
return aiGetMaterialIntegerArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0); return aiGetMaterialIntegerArray(pMat,pKey,type,index,pOut,(unsigned int*)0x0);
@ -1537,7 +1537,7 @@ ASSIMP_API aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
aiString* path, aiString* path,
aiTextureMapping* mapping = NULL, aiTextureMapping* mapping = NULL,
unsigned int* uvindex = NULL, unsigned int* uvindex = NULL,
float* blend = NULL, ai_real* blend = NULL,
aiTextureOp* op = NULL, aiTextureOp* op = NULL,
aiTextureMapMode* mapmode = NULL, aiTextureMapMode* mapmode = NULL,
unsigned int* flags = NULL); unsigned int* flags = NULL);
@ -1548,7 +1548,7 @@ C_ENUM aiReturn aiGetMaterialTexture(const C_STRUCT aiMaterial* mat,
C_STRUCT aiString* path, C_STRUCT aiString* path,
C_ENUM aiTextureMapping* mapping /*= NULL*/, C_ENUM aiTextureMapping* mapping /*= NULL*/,
unsigned int* uvindex /*= NULL*/, unsigned int* uvindex /*= NULL*/,
float* blend /*= NULL*/, ai_real* blend /*= NULL*/,
C_ENUM aiTextureOp* op /*= NULL*/, C_ENUM aiTextureOp* op /*= NULL*/,
C_ENUM aiTextureMapMode* mapmode /*= NULL*/, C_ENUM aiTextureMapMode* mapmode /*= NULL*/,
unsigned int* flags /*= NULL*/); unsigned int* flags /*= NULL*/);

View File

@ -55,7 +55,7 @@ inline aiReturn aiMaterial::GetTexture( aiTextureType type,
C_STRUCT aiString* path, C_STRUCT aiString* path,
aiTextureMapping* mapping /*= NULL*/, aiTextureMapping* mapping /*= NULL*/,
unsigned int* uvindex /*= NULL*/, unsigned int* uvindex /*= NULL*/,
float* blend /*= NULL*/, ai_real* blend /*= NULL*/,
aiTextureOp* op /*= NULL*/, aiTextureOp* op /*= NULL*/,
aiTextureMapMode* mapmode /*= NULL*/) const aiTextureMapMode* mapmode /*= NULL*/) const
{ {
@ -123,7 +123,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,float* pOut, unsigned int idx,ai_real* pOut,
unsigned int* pMax) const unsigned int* pMax) const
{ {
return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax); return ::aiGetMaterialFloatArray(this,pKey,type,idx,pOut,pMax);
@ -137,7 +137,7 @@ inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type, inline aiReturn aiMaterial::Get(const char* pKey,unsigned int type,
unsigned int idx,float& pOut) const unsigned int idx,ai_real& pOut) const
{ {
return aiGetMaterialFloat(this,pKey,type,idx,&pOut); return aiGetMaterialFloat(this,pKey,type,idx,&pOut);
} }
@ -209,7 +209,7 @@ inline aiReturn aiMaterial::AddProperty(const double* pInput,
unsigned int index) unsigned int index)
{ {
return AddBinaryProperty((const void*)pInput, return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(float), pNumValues * sizeof(double),
pKey,type,index,aiPTI_Double); pKey,type,index,aiPTI_Double);
} }
@ -222,7 +222,7 @@ inline aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
{ {
return AddBinaryProperty((const void*)pInput, return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(aiUVTransform), pNumValues * sizeof(aiUVTransform),
pKey,type,index,aiPTI_Float); pKey,type,index,aiPTI_Float); //TODO could be Double ...
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -234,7 +234,7 @@ inline aiReturn aiMaterial::AddProperty(const aiColor4D* pInput,
{ {
return AddBinaryProperty((const void*)pInput, return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(aiColor4D), pNumValues * sizeof(aiColor4D),
pKey,type,index,aiPTI_Float); pKey,type,index,aiPTI_Float); //TODO could be Double ...
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -246,7 +246,7 @@ inline aiReturn aiMaterial::AddProperty(const aiColor3D* pInput,
{ {
return AddBinaryProperty((const void*)pInput, return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(aiColor3D), pNumValues * sizeof(aiColor3D),
pKey,type,index,aiPTI_Float); pKey,type,index,aiPTI_Float); //TODO could be Double ...
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -258,7 +258,7 @@ inline aiReturn aiMaterial::AddProperty(const aiVector3D* pInput,
{ {
return AddBinaryProperty((const void*)pInput, return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(aiVector3D), pNumValues * sizeof(aiVector3D),
pKey,type,index,aiPTI_Float); pKey,type,index,aiPTI_Float); //TODO could be Double ...
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -293,6 +293,19 @@ inline aiReturn aiMaterial::AddProperty<float>(const float* pInput,
pKey,type,index,aiPTI_Float); pKey,type,index,aiPTI_Float);
} }
// ---------------------------------------------------------------------------
template<>
inline aiReturn aiMaterial::AddProperty<double>(const double* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
unsigned int index)
{
return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(double),
pKey,type,index,aiPTI_Double);
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
template<> template<>
inline aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput, inline aiReturn aiMaterial::AddProperty<aiUVTransform>(const aiUVTransform* pInput,

View File

@ -3,7 +3,7 @@
// It takes a file name as command line parameter, loads it using standard // It takes a file name as command line parameter, loads it using standard
// settings and displays it. // settings and displays it.
// //
// If you intend to _use_ this code sample in your app, do yourself a favour // If you intend to _use_ this code sample in your app, do yourself a favour
// and replace immediate mode calls with VBOs ... // and replace immediate mode calls with VBOs ...
// //
// The vc8 solution links against assimp-release-dll_win32 - be sure to // The vc8 solution links against assimp-release-dll_win32 - be sure to
@ -49,9 +49,9 @@ void reshape(int width, int height)
} }
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
void get_bounding_box_for_node (const struct aiNode* nd, void get_bounding_box_for_node (const struct aiNode* nd,
struct aiVector3D* min, struct aiVector3D* min,
struct aiVector3D* max, struct aiVector3D* max,
struct aiMatrix4x4* trafo struct aiMatrix4x4* trafo
){ ){
struct aiMatrix4x4 prev; struct aiMatrix4x4 prev;
@ -123,7 +123,7 @@ void apply_material(const struct aiMaterial *mtl)
struct aiColor4D specular; struct aiColor4D specular;
struct aiColor4D ambient; struct aiColor4D ambient;
struct aiColor4D emission; struct aiColor4D emission;
float shininess, strength; ai_real shininess, strength;
int two_sided; int two_sided;
int wireframe; int wireframe;
unsigned int max; unsigned int max;
@ -174,7 +174,7 @@ void apply_material(const struct aiMaterial *mtl)
max = 1; max = 1;
if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided) if((AI_SUCCESS == aiGetMaterialIntegerArray(mtl, AI_MATKEY_TWOSIDED, &two_sided, &max)) && two_sided)
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
else else
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
} }
@ -219,7 +219,7 @@ void recursive_render (const struct aiScene *sc, const struct aiNode* nd)
int index = face->mIndices[i]; int index = face->mIndices[i];
if(mesh->mColors[0] != NULL) if(mesh->mColors[0] != NULL)
glColor4fv((GLfloat*)&mesh->mColors[0][index]); glColor4fv((GLfloat*)&mesh->mColors[0][index]);
if(mesh->mNormals != NULL) if(mesh->mNormals != NULL)
glNormal3fv(&mesh->mNormals[index].x); glNormal3fv(&mesh->mNormals[index].x);
glVertex3fv(&mesh->mVertices[index].x); glVertex3fv(&mesh->mVertices[index].x);
} }
@ -347,11 +347,11 @@ int main(int argc, char **argv)
aiAttachLogStream(&stream); aiAttachLogStream(&stream);
/* the model name can be specified on the command line. If none /* the model name can be specified on the command line. If none
is specified, we try to locate one of the more expressive test is specified, we try to locate one of the more expressive test
models from the repository (/models-nonbsd may be missing in models from the repository (/models-nonbsd may be missing in
some distributions so we need a fallback from /models!). */ some distributions so we need a fallback from /models!). */
if( 0 != loadasset( argc >= 2 ? argv[1] : "../../test/models-nonbsd/X/dwarf.x")) { if( 0 != loadasset( argc >= 2 ? argv[1] : "../../test/models-nonbsd/X/dwarf.x")) {
if( argc != 1 || (0 != loadasset( "../../../../test/models-nonbsd/X/dwarf.x") && 0 != loadasset( "../../test/models/X/Testwuson.X"))) { if( argc != 1 || (0 != loadasset( "../../../../test/models-nonbsd/X/dwarf.x") && 0 != loadasset( "../../test/models/X/Testwuson.X"))) {
return -1; return -1;
} }
} }
@ -367,7 +367,7 @@ int main(int argc, char **argv)
glEnable(GL_NORMALIZE); glEnable(GL_NORMALIZE);
/* XXX docs say all polygons are emitted CCW, but tests show that some aren't. */ /* XXX docs say all polygons are emitted CCW, but tests show that some aren't. */
if(getenv("MODEL_IS_BROKEN")) if(getenv("MODEL_IS_BROKEN"))
glFrontFace(GL_CW); glFrontFace(GL_CW);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
@ -375,8 +375,8 @@ int main(int argc, char **argv)
glutGet(GLUT_ELAPSED_TIME); glutGet(GLUT_ELAPSED_TIME);
glutMainLoop(); glutMainLoop();
/* cleanup - calling 'aiReleaseImport' is important, as the library /* cleanup - calling 'aiReleaseImport' is important, as the library
keeps internal resources until the scene is freed again. Not keeps internal resources until the scene is freed again. Not
doing so can cause severe resource leaking. */ doing so can cause severe resource leaking. */
aiReleaseImport(scene); aiReleaseImport(scene);
@ -386,4 +386,3 @@ int main(int argc, char **argv)
aiDetachAllLogStreams(); aiDetachAllLogStreams();
return 0; return 0;
} }

View File

@ -142,13 +142,13 @@ bool Import3DFromFile( const std::string& pFile)
} }
// Resize And Initialize The GL Window // Resize And Initialize The GL Window
void ReSizeGLScene(GLsizei width, GLsizei height) void ReSizeGLScene(GLsizei width, GLsizei height)
{ {
// Prevent A Divide By Zero By // Prevent A Divide By Zero By
if (height==0) if (height==0)
{ {
// Making Height Equal One // Making Height Equal One
height=1; height=1;
} }
glViewport(0, 0, width, height); // Reset The Current Viewport glViewport(0, 0, width, height); // Reset The Current Viewport
@ -236,7 +236,7 @@ int LoadGLTextures(const aiScene* scene)
if (success) /* If no error occurred: */ if (success) /* If no error occurred: */
{ {
// Convert every colour component into unsigned byte.If your image contains // Convert every colour component into unsigned byte.If your image contains
// alpha channel you can replace IL_RGB with IL_RGBA // alpha channel you can replace IL_RGB with IL_RGBA
success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); success = ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE);
if (!success) if (!success)
@ -246,7 +246,7 @@ int LoadGLTextures(const aiScene* scene)
return -1; return -1;
} }
// Binding of texture name // Binding of texture name
glBindTexture(GL_TEXTURE_2D, textureIds[i]); glBindTexture(GL_TEXTURE_2D, textureIds[i]);
// redefine standard texture values // redefine standard texture values
// We will use linear interpolation for magnification filter // We will use linear interpolation for magnification filter
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
@ -255,7 +255,7 @@ int LoadGLTextures(const aiScene* scene)
// Texture specification // Texture specification
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH), glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData()); ilGetData());
// we also want to be able to deal with odd texture dimensions // we also want to be able to deal with odd texture dimensions
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
@ -269,7 +269,7 @@ int LoadGLTextures(const aiScene* scene)
} }
} }
// Because we have already copied image data into texture data we can release memory used by image. // Because we have already copied image data into texture data we can release memory used by image.
ilDeleteImages(numTextures, imageIds); ilDeleteImages(numTextures, imageIds);
// Cleanup // Cleanup
delete [] imageIds; delete [] imageIds;
@ -342,7 +342,7 @@ void apply_material(const aiMaterial *mtl)
aiColor4D specular; aiColor4D specular;
aiColor4D ambient; aiColor4D ambient;
aiColor4D emission; aiColor4D emission;
float shininess, strength; ai_real shininess, strength;
int two_sided; int two_sided;
int wireframe; int wireframe;
unsigned int max; // changed: to unsigned unsigned int max; // changed: to unsigned