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 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); }