From 50334086cfb693f720d18d1664d177e63d200f0d Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Tue, 11 Feb 2020 11:42:13 -0500 Subject: [PATCH 1/7] Added missing texture types when searching for invalid textures. --- code/PostProcessing/ValidateDataStructure.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index a812efb0b..6212bfb69 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -777,6 +777,12 @@ void ValidateDSProcess::Validate( const aiMaterial* pMaterial) SearchForInvalidTextures(pMaterial,aiTextureType_DISPLACEMENT); SearchForInvalidTextures(pMaterial,aiTextureType_LIGHTMAP); SearchForInvalidTextures(pMaterial,aiTextureType_REFLECTION); + SearchForInvalidTextures(pMaterial,aiTextureType_BASE_COLOR); + SearchForInvalidTextures(pMaterial,aiTextureType_NORMAL_CAMERA); + SearchForInvalidTextures(pMaterial,aiTextureType_EMISSION_COLOR); + SearchForInvalidTextures(pMaterial,aiTextureType_METALNESS); + SearchForInvalidTextures(pMaterial,aiTextureType_DIFFUSE_ROUGHNESS); + SearchForInvalidTextures(pMaterial,aiTextureType_AMBIENT_OCCLUSION); } // ------------------------------------------------------------------------------------------------ From fc4dd6455a87fc01a9ef734d64718945207b09f2 Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Thu, 13 Feb 2020 00:10:07 +0200 Subject: [PATCH 2/7] minor code improvements for the obj code - make use of range for loops - make use of empty() method for the std::vector - removed unnecessary std::string initialization - use ' ' instead of " " for the find methods (should be "faster") - simplified some function - make use of emplace_back instead of push_back (should be "faster") - other small changes --- code/Obj/ObjFileImporter.cpp | 49 +++++++++++++++------------------ code/Obj/ObjFileMtlImporter.cpp | 4 +-- code/Obj/ObjFileParser.cpp | 36 ++++++++++-------------- code/Obj/ObjFileParser.h | 2 +- 4 files changed, 39 insertions(+), 52 deletions(-) diff --git a/code/Obj/ObjFileImporter.cpp b/code/Obj/ObjFileImporter.cpp index 7e2df0fc5..d73cc5b32 100644 --- a/code/Obj/ObjFileImporter.cpp +++ b/code/Obj/ObjFileImporter.cpp @@ -175,15 +175,15 @@ void ObjFileImporter::CreateDataFromImport(const ObjFile::Model* pModel, aiScene ai_assert(false); } - if (pModel->m_Objects.size() > 0) { + if (!pModel->m_Objects.empty()) { unsigned int meshCount = 0; unsigned int childCount = 0; - for(size_t index = 0; index < pModel->m_Objects.size(); ++index) { - if(pModel->m_Objects[index]) { + for (auto object : pModel->m_Objects) { + if(object) { ++childCount; - meshCount += (unsigned int)pModel->m_Objects[index]->m_Meshes.size(); + meshCount += (unsigned int)object->m_Meshes.size(); } } @@ -365,8 +365,8 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj unsigned int outIndex( 0 ); // Copy all data from all stored meshes - for (size_t index = 0; index < pObjMesh->m_Faces.size(); index++) { - ObjFile::Face* const inp = pObjMesh->m_Faces[ index ]; + for (auto& face : pObjMesh->m_Faces) { + ObjFile::Face* const inp = face; if (inp->m_PrimitiveType == aiPrimitiveType_LINE) { for(size_t i = 0; i < inp->m_vertices.size() - 1; ++i) { aiFace& f = pMesh->mFaces[ outIndex++ ]; @@ -385,7 +385,7 @@ aiMesh *ObjFileImporter::createTopology( const ObjFile::Model* pModel, const Obj } aiFace *pFace = &pMesh->mFaces[ outIndex++ ]; - const unsigned int uiNumIndices = (unsigned int) pObjMesh->m_Faces[ index ]->m_vertices.size(); + const unsigned int uiNumIndices = (unsigned int) face->m_vertices.size(); uiIdxCount += pFace->mNumIndices = (unsigned int) uiNumIndices; if (pFace->mNumIndices > 0) { pFace->mIndices = new unsigned int[ uiNumIndices ]; @@ -446,13 +446,10 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, // Copy vertices, normals and textures into aiMesh instance bool normalsok = true, uvok = true; unsigned int newIndex = 0, outIndex = 0; - for ( size_t index=0; index < pObjMesh->m_Faces.size(); index++ ) { - // Get source face - ObjFile::Face *pSourceFace = pObjMesh->m_Faces[ index ]; - + for (auto sourceFace : pObjMesh->m_Faces) { // Copy all index arrays - for ( size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < pSourceFace->m_vertices.size(); vertexIndex++ ) { - const unsigned int vertex = pSourceFace->m_vertices.at( vertexIndex ); + for (size_t vertexIndex = 0, outVertexIndex = 0; vertexIndex < sourceFace->m_vertices.size(); vertexIndex++ ) { + const unsigned int vertex = sourceFace->m_vertices.at(vertexIndex ); if ( vertex >= pModel->m_Vertices.size() ) { throw DeadlyImportError( "OBJ: vertex index out of range" ); } @@ -464,8 +461,8 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, pMesh->mVertices[ newIndex ] = pModel->m_Vertices[ vertex ]; // Copy all normals - if ( normalsok && !pModel->m_Normals.empty() && vertexIndex < pSourceFace->m_normals.size()) { - const unsigned int normal = pSourceFace->m_normals.at( vertexIndex ); + if ( normalsok && !pModel->m_Normals.empty() && vertexIndex < sourceFace->m_normals.size()) { + const unsigned int normal = sourceFace->m_normals.at(vertexIndex ); if ( normal >= pModel->m_Normals.size() ) { normalsok = false; @@ -484,9 +481,9 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, } // Copy all texture coordinates - if ( uvok && !pModel->m_TextureCoord.empty() && vertexIndex < pSourceFace->m_texturCoords.size()) + if ( uvok && !pModel->m_TextureCoord.empty() && vertexIndex < sourceFace->m_texturCoords.size()) { - const unsigned int tex = pSourceFace->m_texturCoords.at( vertexIndex ); + const unsigned int tex = sourceFace->m_texturCoords.at(vertexIndex ); if ( tex >= pModel->m_TextureCoord.size() ) { @@ -502,16 +499,16 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, // Get destination face aiFace *pDestFace = &pMesh->mFaces[ outIndex ]; - const bool last = ( vertexIndex == pSourceFace->m_vertices.size() - 1 ); - if (pSourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last) { + const bool last = (vertexIndex == sourceFace->m_vertices.size() - 1 ); + if (sourceFace->m_PrimitiveType != aiPrimitiveType_LINE || !last) { pDestFace->mIndices[ outVertexIndex ] = newIndex; outVertexIndex++; } - if (pSourceFace->m_PrimitiveType == aiPrimitiveType_POINT) { + if (sourceFace->m_PrimitiveType == aiPrimitiveType_POINT) { outIndex++; outVertexIndex = 0; - } else if (pSourceFace->m_PrimitiveType == aiPrimitiveType_LINE) { + } else if (sourceFace->m_PrimitiveType == aiPrimitiveType_LINE) { outVertexIndex = 0; if(!last) @@ -520,7 +517,7 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, if (vertexIndex) { if(!last) { pMesh->mVertices[ newIndex+1 ] = pMesh->mVertices[ newIndex ]; - if ( !pSourceFace->m_normals.empty() && !pModel->m_Normals.empty()) { + if (!sourceFace->m_normals.empty() && !pModel->m_Normals.empty()) { pMesh->mNormals[ newIndex+1 ] = pMesh->mNormals[newIndex ]; } if ( !pModel->m_TextureCoord.empty() ) { @@ -563,13 +560,11 @@ void ObjFileImporter::countObjects(const std::vector &rObjects return; iNumMeshes += static_cast( rObjects.size() ); - for (std::vector::const_iterator it = rObjects.begin(); - it != rObjects.end(); - ++it) + for (auto object: rObjects) { - if (!(*it)->m_SubObjects.empty()) + if (!object->m_SubObjects.empty()) { - countObjects((*it)->m_SubObjects, iNumMeshes); + countObjects(object->m_SubObjects, iNumMeshes); } } } diff --git a/code/Obj/ObjFileMtlImporter.cpp b/code/Obj/ObjFileMtlImporter.cpp index cdd60f03c..90c70cda3 100644 --- a/code/Obj/ObjFileMtlImporter.cpp +++ b/code/Obj/ObjFileMtlImporter.cpp @@ -274,7 +274,7 @@ void ObjFileMtlImporter::getFloatValue( ai_real &value ) // Creates a material from loaded data. void ObjFileMtlImporter::createMaterial() { - std::string line( "" ); + std::string line; while( !IsLineEnd( *m_DataIt ) ) { line += *m_DataIt; ++m_DataIt; @@ -282,7 +282,7 @@ void ObjFileMtlImporter::createMaterial() std::vector token; const unsigned int numToken = tokenize( line, token, " \t" ); - std::string name( "" ); + std::string name; if ( numToken == 1 ) { name = AI_DEFAULT_MATERIAL_NAME; } else { diff --git a/code/Obj/ObjFileParser.cpp b/code/Obj/ObjFileParser.cpp index 7e3b11b23..9e1e28ae6 100644 --- a/code/Obj/ObjFileParser.cpp +++ b/code/Obj/ObjFileParser.cpp @@ -96,9 +96,6 @@ ObjFileParser::ObjFileParser( IOStreamBuffer &streamBuffer, const std::str parseFile( streamBuffer ); } -ObjFileParser::~ObjFileParser() { -} - void ObjFileParser::setBuffer( std::vector &buffer ) { m_DataIt = buffer.begin(); m_DataItEnd = buffer.end(); @@ -182,7 +179,7 @@ void ObjFileParser::parseFile( IOStreamBuffer &streamBuffer ) { getNameNoSpace(m_DataIt, m_DataItEnd, name); - size_t nextSpace = name.find(" "); + size_t nextSpace = name.find(' '); if (nextSpace != std::string::npos) name = name.substr(0, nextSpace); @@ -199,7 +196,7 @@ void ObjFileParser::parseFile( IOStreamBuffer &streamBuffer ) { getNameNoSpace(m_DataIt, m_DataItEnd, name); - size_t nextSpace = name.find(" "); + size_t nextSpace = name.find(' '); if (nextSpace != std::string::npos) name = name.substr(0, nextSpace); @@ -274,13 +271,8 @@ static bool isDataDefinitionEnd( const char *tmp ) { static bool isNanOrInf(const char * in) { // Look for "nan" or "inf", case insensitive - if ((in[0] == 'N' || in[0] == 'n') && ASSIMP_strincmp(in, "nan", 3) == 0) { - return true; - } - else if ((in[0] == 'I' || in[0] == 'i') && ASSIMP_strincmp(in, "inf", 3) == 0) { - return true; - } - return false; + return ((in[0] == 'N' || in[0] == 'n') && ASSIMP_strincmp(in, "nan", 3) == 0) || + ((in[0] == 'I' || in[0] == 'i') && ASSIMP_strincmp(in, "inf", 3) == 0); } size_t ObjFileParser::getNumComponentsInDataDefinition() { @@ -341,7 +333,7 @@ size_t ObjFileParser::getTexCoordVector( std::vector &point3d_array if (!std::isfinite(z)) z = 0; - point3d_array.push_back( aiVector3D( x, y, z ) ); + point3d_array.emplace_back( x, y, z ); m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); return numComponents; } @@ -357,7 +349,7 @@ void ObjFileParser::getVector3( std::vector &point3d_array ) { copyNextWord( m_buffer, Buffersize ); z = ( ai_real ) fast_atof( m_buffer ); - point3d_array.push_back( aiVector3D( x, y, z ) ); + point3d_array.emplace_back( x, y, z ); m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } @@ -378,7 +370,7 @@ void ObjFileParser::getHomogeneousVector3( std::vector &point3d_arra if (w == 0) throw DeadlyImportError("OBJ: Invalid component in homogeneous vector (Division by zero)"); - point3d_array.push_back( aiVector3D( x/w, y/w, z/w ) ); + point3d_array.emplace_back( x/w, y/w, z/w ); m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } @@ -393,7 +385,7 @@ void ObjFileParser::getTwoVectors3( std::vector &point3d_array_a, st copyNextWord( m_buffer, Buffersize ); z = ( ai_real ) fast_atof( m_buffer ); - point3d_array_a.push_back( aiVector3D( x, y, z ) ); + point3d_array_a.emplace_back( x, y, z ); copyNextWord(m_buffer, Buffersize); x = (ai_real) fast_atof(m_buffer); @@ -404,7 +396,7 @@ void ObjFileParser::getTwoVectors3( std::vector &point3d_array_a, st copyNextWord( m_buffer, Buffersize ); z = ( ai_real ) fast_atof( m_buffer ); - point3d_array_b.push_back( aiVector3D( x, y, z ) ); + point3d_array_b.emplace_back( x, y, z ); m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } @@ -417,7 +409,7 @@ void ObjFileParser::getVector2( std::vector &point2d_array ) { copyNextWord(m_buffer, Buffersize); y = (ai_real) fast_atof(m_buffer); - point2d_array.push_back(aiVector2D(x, y)); + point2d_array.emplace_back(x, y); m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } @@ -439,7 +431,7 @@ void ObjFileParser::getFace( aiPrimitiveType type ) { const bool vt = (!m_pModel->m_TextureCoord.empty()); const bool vn = (!m_pModel->m_Normals.empty()); - int iStep = 0, iPos = 0; + int iStep, iPos = 0; while ( m_DataIt != m_DataItEnd ) { iStep = 1; @@ -845,18 +837,18 @@ void ObjFileParser::createMesh( const std::string &meshName ) bool ObjFileParser::needsNewMesh( const std::string &materialName ) { // If no mesh data yet - if(m_pModel->m_pCurrentMesh == 0) + if (m_pModel->m_pCurrentMesh == nullptr) { return true; } bool newMat = false; int matIdx = getMaterialIndex( materialName ); - int curMatIdx = m_pModel->m_pCurrentMesh->m_uiMaterialIndex; + unsigned int curMatIdx = m_pModel->m_pCurrentMesh->m_uiMaterialIndex; if ( curMatIdx != int(ObjFile::Mesh::NoMaterial) && curMatIdx != matIdx // no need create a new mesh if no faces in current // lets say 'usemtl' goes straight after 'g' - && m_pModel->m_pCurrentMesh->m_Faces.size() > 0 ) + && !m_pModel->m_pCurrentMesh->m_Faces.empty() ) { // New material -> only one material per mesh, so we need to create a new // material diff --git a/code/Obj/ObjFileParser.h b/code/Obj/ObjFileParser.h index 124527413..05704c981 100644 --- a/code/Obj/ObjFileParser.h +++ b/code/Obj/ObjFileParser.h @@ -80,7 +80,7 @@ public: /// @brief Constructor with data array. ObjFileParser( IOStreamBuffer &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, const std::string &originalObjFileName); /// @brief Destructor - ~ObjFileParser(); + ~ObjFileParser() = default; /// @brief If you want to load in-core data. void setBuffer( std::vector &buffer ); /// @brief Model getter. From 24cdb1f22184adaabb9155ac303c888843e0a7b7 Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Thu, 13 Feb 2020 00:21:04 +0200 Subject: [PATCH 3/7] revert small change --- code/Obj/ObjFileParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Obj/ObjFileParser.cpp b/code/Obj/ObjFileParser.cpp index 9e1e28ae6..e33d2e028 100644 --- a/code/Obj/ObjFileParser.cpp +++ b/code/Obj/ObjFileParser.cpp @@ -843,7 +843,7 @@ bool ObjFileParser::needsNewMesh( const std::string &materialName ) } bool newMat = false; int matIdx = getMaterialIndex( materialName ); - unsigned int curMatIdx = m_pModel->m_pCurrentMesh->m_uiMaterialIndex; + int curMatIdx = m_pModel->m_pCurrentMesh->m_uiMaterialIndex; if ( curMatIdx != int(ObjFile::Mesh::NoMaterial) && curMatIdx != matIdx // no need create a new mesh if no faces in current From 6f1870681bf5a37ac21a8fd8fb47d753431e2677 Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Thu, 13 Feb 2020 00:27:30 +0200 Subject: [PATCH 4/7] reduced the scope of iStep variable --- code/Obj/ObjFileParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/Obj/ObjFileParser.cpp b/code/Obj/ObjFileParser.cpp index e33d2e028..500325993 100644 --- a/code/Obj/ObjFileParser.cpp +++ b/code/Obj/ObjFileParser.cpp @@ -431,9 +431,9 @@ void ObjFileParser::getFace( aiPrimitiveType type ) { const bool vt = (!m_pModel->m_TextureCoord.empty()); const bool vn = (!m_pModel->m_Normals.empty()); - int iStep, iPos = 0; + int iPos = 0; while ( m_DataIt != m_DataItEnd ) { - iStep = 1; + int iStep = 1; if ( IsLineEnd( *m_DataIt ) ) { break; From 25feb77982aefd895769dc0b79a3b50e0f05dae2 Mon Sep 17 00:00:00 2001 From: iamAdrianIusca Date: Thu, 13 Feb 2020 00:38:56 +0200 Subject: [PATCH 5/7] more minor changes --- code/Obj/ObjFileParser.cpp | 3 +++ code/Obj/ObjFileParser.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code/Obj/ObjFileParser.cpp b/code/Obj/ObjFileParser.cpp index 500325993..48129c02c 100644 --- a/code/Obj/ObjFileParser.cpp +++ b/code/Obj/ObjFileParser.cpp @@ -96,6 +96,9 @@ ObjFileParser::ObjFileParser( IOStreamBuffer &streamBuffer, const std::str parseFile( streamBuffer ); } +ObjFileParser::~ObjFileParser() { +} + void ObjFileParser::setBuffer( std::vector &buffer ) { m_DataIt = buffer.begin(); m_DataItEnd = buffer.end(); diff --git a/code/Obj/ObjFileParser.h b/code/Obj/ObjFileParser.h index 05704c981..124527413 100644 --- a/code/Obj/ObjFileParser.h +++ b/code/Obj/ObjFileParser.h @@ -80,7 +80,7 @@ public: /// @brief Constructor with data array. ObjFileParser( IOStreamBuffer &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, const std::string &originalObjFileName); /// @brief Destructor - ~ObjFileParser() = default; + ~ObjFileParser(); /// @brief If you want to load in-core data. void setBuffer( std::vector &buffer ); /// @brief Model getter. From d9042e46098a903de391e74ac1f5f12340c3cfee Mon Sep 17 00:00:00 2001 From: Marc-Antoine Lortie Date: Sat, 15 Feb 2020 18:02:12 -0500 Subject: [PATCH 6/7] Fixed SimpleTexturedOpenGL sample. Several places in the sample's code were calling Unicode versions of Win32 functions with "multibyte" strings. A few changes were required to fix it. I added a class "UTFConverter", which handles calls to unicode/multibyte string conversions. This should help minimize the impacts on code change in case C++'s codecvt_utf8 ever changes. In addition, seveal memory leaks have been found, but these fixes will come in another PR because it goes beyond the scope of this PR. DevIL.lib was removed in CMakeFiles.txt, as it is unused in the sample. Here is a list of the changes: - Fixed MB string calls to Unicode functions. - Added class UTFConverter to handle string conversions. - Removed reference to DevIL.lib. - Fixed compile warnings. --- samples/SimpleTexturedOpenGL/CMakeLists.txt | 2 +- .../src/model_loading.cpp | 74 +++++++++++++------ 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt index 40138c49b..941e18cea 100644 --- a/samples/SimpleTexturedOpenGL/CMakeLists.txt +++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt @@ -35,7 +35,7 @@ ADD_EXECUTABLE( assimp_simpletexturedogl WIN32 SET_PROPERTY(TARGET assimp_simpletexturedogl PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) -TARGET_LINK_LIBRARIES( assimp_simpletexturedogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} DevIL.lib ) +TARGET_LINK_LIBRARIES( assimp_simpletexturedogl assimp ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ) SET_TARGET_PROPERTIES( assimp_simpletexturedogl PROPERTIES OUTPUT_NAME assimp_simpletexturedogl diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 8d25aaaed..8428248d1 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -21,6 +21,8 @@ #define STB_IMAGE_IMPLEMENTATION #include "contrib/stb_image/stb_image.h" +#include +#include #include //to map image filenames to textureIds @@ -75,6 +77,36 @@ GLuint* textureIds; // pointer to texture Array // Create an instance of the Importer class Assimp::Importer importer; +// Used to convert between multibyte and unicode strings. +class UTFConverter { + using UTFConverterImpl = std::wstring_convert, wchar_t>; +public: + UTFConverter(const char* s) : + s_(s), + ws_(impl_.from_bytes(s)) { + } + UTFConverter(const std::string& s) : + s_(s), + ws_(impl_.from_bytes(s)) { + } + UTFConverter(const std::wstring& s) : + s_(impl_.to_bytes(s)), + ws_(s) { + } + inline const std::string& str() const { + return s_; + } + inline const wchar_t* c_wstr() const { + return ws_.c_str(); + } +private: + static UTFConverterImpl impl_; + std::string s_; + std::wstring ws_; +}; + +typename UTFConverter::UTFConverterImpl UTFConverter::impl_; + void createAILogger() { // Change this line to normal if you not want to analyse the import process @@ -120,7 +152,7 @@ bool Import3DFromFile( const std::string& pFile) } else { - MessageBox(NULL, ("Couldn't open file: " + pFile).c_str() , "ERROR", MB_OK | MB_ICONEXCLAMATION); + MessageBox(NULL, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION); logInfo( importer.GetErrorString()); return false; } @@ -205,7 +237,7 @@ int LoadGLTextures(const aiScene* scene) } } - int numTextures = textureIdMap.size(); + const size_t numTextures = textureIdMap.size(); /* array with DevIL image IDs */ @@ -217,13 +249,13 @@ int LoadGLTextures(const aiScene* scene) /* create and fill array with GL texture ids */ textureIds = new GLuint[numTextures]; - glGenTextures(numTextures, textureIds); /* Texture name generation */ + glGenTextures(static_cast(numTextures), textureIds); /* Texture name generation */ /* get iterator */ std::map::iterator itr = textureIdMap.begin(); std::string basepath = getBasePath(modelpath); - for (int i=0; i 1) { std::wstring modelpathW(argv[1]); - modelpath = std::string(modelpathW.begin(), modelpathW.end()); + modelpath = UTFConverter(modelpathW).str(); } if (!Import3DFromFile(modelpath)) return 0; logInfo("=============== Post Import ===================="); - if (MessageBox(NULL, "Would You Like To Run In Fullscreen Mode?", "Start Fullscreen?", MB_YESNO|MB_ICONEXCLAMATION)==IDNO) + if (MessageBox(NULL, TEXT("Would You Like To Run In Fullscreen Mode?"), TEXT("Start Fullscreen?"), MB_YESNO|MB_ICONEXCLAMATION)==IDNO) { fullscreen=FALSE; } @@ -881,5 +913,5 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance destroyAILogger(); KillGLWindow(); - return (msg.wParam); + return static_cast(msg.wParam); } From eb8abfa02cc76f41ce93f3832972fb490f3b9321 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 16 Feb 2020 12:37:46 +0100 Subject: [PATCH 7/7] Update .clang-format Disable tabs. --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index eba6d586f..70e0945fe 100644 --- a/.clang-format +++ b/.clang-format @@ -108,7 +108,7 @@ IndentWidth: 4 # SpacesInParentheses: false # SpacesInSquareBrackets: false TabWidth: 4 -UseTab: Always +UseTab: Never --- ### C++ specific config ### Language: Cpp