Merge branch 'master' into common-directory-for-compiled-binaries
commit
2d382c5e76
|
@ -71,7 +71,7 @@ IncludeCategories:
|
||||||
Priority: 3
|
Priority: 3
|
||||||
# IncludeIsMainRegex: '(Test)?$'
|
# IncludeIsMainRegex: '(Test)?$'
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
# IndentPPDirectives: None
|
IndentPPDirectives: AfterHash
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
# IndentWrappedFunctionNames: false
|
# IndentWrappedFunctionNames: false
|
||||||
# JavaScriptQuotes: Leave
|
# JavaScriptQuotes: Leave
|
||||||
|
@ -108,7 +108,7 @@ IndentWidth: 4
|
||||||
# SpacesInParentheses: false
|
# SpacesInParentheses: false
|
||||||
# SpacesInSquareBrackets: false
|
# SpacesInSquareBrackets: false
|
||||||
TabWidth: 4
|
TabWidth: 4
|
||||||
UseTab: Always
|
UseTab: Never
|
||||||
---
|
---
|
||||||
### C++ specific config ###
|
### C++ specific config ###
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
|
|
|
@ -441,10 +441,6 @@ ELSE(HUNTER_ENABLED)
|
||||||
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||||
ENDIF(HUNTER_ENABLED)
|
ENDIF(HUNTER_ENABLED)
|
||||||
|
|
||||||
if (ASSIMP_BUILD_SAMPLES OR ASSIMP_BUILD_SAMPLES)
|
|
||||||
FIND_PACKAGE(DirectX)
|
|
||||||
endif(ASSIMP_BUILD_SAMPLES OR ASSIMP_BUILD_SAMPLES)
|
|
||||||
|
|
||||||
IF( BUILD_DOCS )
|
IF( BUILD_DOCS )
|
||||||
ADD_SUBDIRECTORY(doc)
|
ADD_SUBDIRECTORY(doc)
|
||||||
ENDIF( BUILD_DOCS )
|
ENDIF( BUILD_DOCS )
|
||||||
|
|
|
@ -191,7 +191,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
||||||
if (pStream.get() ) {
|
if (pStream) {
|
||||||
// read 200 characters from the file
|
// read 200 characters from the file
|
||||||
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
|
||||||
char *buffer( _buffer.get() );
|
char *buffer( _buffer.get() );
|
||||||
|
@ -283,7 +283,6 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// thanks to Andy Maloney for the hint
|
// thanks to Andy Maloney for the hint
|
||||||
std::string ret = file.substr( pos + 1 );
|
std::string ret = file.substr( pos + 1 );
|
||||||
std::transform( ret.begin(), ret.end(), ret.begin(), ToLower<char>);
|
std::transform( ret.begin(), ret.end(), ret.begin(), ToLower<char>);
|
||||||
|
@ -309,7 +308,7 @@ std::string BaseImporter::GetExtension( const std::string& file ) {
|
||||||
};
|
};
|
||||||
magic = reinterpret_cast<const char*>(_magic);
|
magic = reinterpret_cast<const char*>(_magic);
|
||||||
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
|
||||||
if (pStream.get() ) {
|
if (pStream) {
|
||||||
|
|
||||||
// skip to offset
|
// skip to offset
|
||||||
pStream->Seek(offset,aiOrigin_SET);
|
pStream->Seek(offset,aiOrigin_SET);
|
||||||
|
@ -603,7 +602,7 @@ unsigned int BatchLoader::AddLoadRequest(const std::string& file,
|
||||||
}
|
}
|
||||||
|
|
||||||
// no, we don't have it. So add it to the queue ...
|
// no, we don't have it. So add it to the queue ...
|
||||||
m_data->requests.push_back(LoadRequest(file,steps,map, m_data->next_id));
|
m_data->requests.emplace_back(file, steps, map, m_data->next_id);
|
||||||
return m_data->next_id++;
|
return m_data->next_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ ai_real Importer::GetPropertyFloat(const char* szName, ai_real iErrorReturn /*=
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get a configuration property
|
// Get a configuration property
|
||||||
const std::string Importer::GetPropertyString(const char* szName, const std::string& iErrorReturn /*= ""*/) const {
|
std::string Importer::GetPropertyString(const char* szName, const std::string& iErrorReturn /*= ""*/) const {
|
||||||
ai_assert(nullptr != pimpl);
|
ai_assert(nullptr != pimpl);
|
||||||
|
|
||||||
return GetGenericProperty<std::string>(pimpl->mStringProperties,szName,iErrorReturn);
|
return GetGenericProperty<std::string>(pimpl->mStringProperties,szName,iErrorReturn);
|
||||||
|
@ -1079,7 +1079,7 @@ const std::string Importer::GetPropertyString(const char* szName, const std::str
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Get a configuration property
|
// Get a configuration property
|
||||||
const aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const {
|
aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const {
|
||||||
ai_assert(nullptr != pimpl);
|
ai_assert(nullptr != pimpl);
|
||||||
|
|
||||||
return GetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties,szName,iErrorReturn);
|
return GetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties,szName,iErrorReturn);
|
||||||
|
@ -1110,10 +1110,9 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
||||||
aiScene* mScene = pimpl->mScene;
|
aiScene* mScene = pimpl->mScene;
|
||||||
|
|
||||||
// return if we have no scene loaded
|
// return if we have no scene loaded
|
||||||
if (!pimpl->mScene)
|
if (!mScene)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
in.total = sizeof(aiScene);
|
in.total = sizeof(aiScene);
|
||||||
|
|
||||||
// add all meshes
|
// add all meshes
|
||||||
|
@ -1202,5 +1201,6 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
|
||||||
in.materials += pc->mProperties[a]->mDataLength;
|
in.materials += pc->mProperties[a]->mDataLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
in.total += in.materials;
|
in.total += in.materials;
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,8 +343,6 @@ namespace Assimp {
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipArchiveIOSystem::Implement::~Implement() {
|
ZipArchiveIOSystem::Implement::~Implement() {
|
||||||
m_ArchiveMap.clear();
|
|
||||||
|
|
||||||
if (m_ZipFileHandle != nullptr) {
|
if (m_ZipFileHandle != nullptr) {
|
||||||
unzClose(m_ZipFileHandle);
|
unzClose(m_ZipFileHandle);
|
||||||
m_ZipFileHandle = nullptr;
|
m_ZipFileHandle = nullptr;
|
||||||
|
|
|
@ -110,10 +110,7 @@ struct Object {
|
||||||
std::vector<unsigned int> m_Meshes;
|
std::vector<unsigned int> m_Meshes;
|
||||||
|
|
||||||
//! \brief Default constructor
|
//! \brief Default constructor
|
||||||
Object()
|
Object() = default;
|
||||||
: m_strObjName("") {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Destructor
|
//! \brief Destructor
|
||||||
~Object() {
|
~Object() {
|
||||||
|
@ -191,16 +188,12 @@ struct Material {
|
||||||
, illumination_model (1)
|
, illumination_model (1)
|
||||||
, ior ( ai_real( 1.0 ) )
|
, ior ( ai_real( 1.0 ) )
|
||||||
, transparent( ai_real( 1.0), ai_real (1.0), ai_real(1.0)) {
|
, transparent( ai_real( 1.0), ai_real (1.0), ai_real(1.0)) {
|
||||||
// empty
|
|
||||||
for (size_t i = 0; i < TextureTypeCount; ++i) {
|
std::fill_n(clamp, static_cast<unsigned int>(TextureTypeCount), false);
|
||||||
clamp[ i ] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
~Material() {
|
~Material() = default;
|
||||||
// empty
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -53,6 +53,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <assimp/material.h>
|
#include <assimp/material.h>
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
@ -71,16 +73,16 @@ ObjFileParser::ObjFileParser()
|
||||||
|
|
||||||
ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName,
|
ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName,
|
||||||
IOSystem *io, ProgressHandler* progress,
|
IOSystem *io, ProgressHandler* progress,
|
||||||
const std::string &originalObjFileName) :
|
std::string originalObjFileName) :
|
||||||
m_DataIt(),
|
m_DataIt(),
|
||||||
m_DataItEnd(),
|
m_DataItEnd(),
|
||||||
m_pModel(nullptr),
|
m_pModel(nullptr),
|
||||||
m_uiLine(0),
|
m_uiLine(0),
|
||||||
m_pIO( io ),
|
m_pIO(io),
|
||||||
m_progress(progress),
|
m_progress(progress),
|
||||||
m_originalObjFileName(originalObjFileName)
|
m_originalObjFileName(std::move(originalObjFileName))
|
||||||
{
|
{
|
||||||
std::fill_n(m_buffer,Buffersize,0);
|
std::fill_n(m_buffer, Buffersize,0);
|
||||||
|
|
||||||
// Create the model instance to store all the data
|
// Create the model instance to store all the data
|
||||||
m_pModel.reset(new ObjFile::Model());
|
m_pModel.reset(new ObjFile::Model());
|
||||||
|
@ -96,7 +98,8 @@ ObjFileParser::ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::str
|
||||||
parseFile( streamBuffer );
|
parseFile( streamBuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjFileParser::~ObjFileParser() {
|
ObjFileParser::~ObjFileParser()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjFileParser::setBuffer( std::vector<char> &buffer ) {
|
void ObjFileParser::setBuffer( std::vector<char> &buffer ) {
|
||||||
|
@ -128,7 +131,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
||||||
processed = static_cast<unsigned int>(filePos);
|
processed = static_cast<unsigned int>(filePos);
|
||||||
lastFilePos = filePos;
|
lastFilePos = filePos;
|
||||||
progressCounter++;
|
progressCounter++;
|
||||||
m_progress->UpdateFileRead( processed, progressTotal );
|
m_progress->UpdateFileRead(processed, progressTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse line
|
// parse line
|
||||||
|
|
|
@ -78,7 +78,7 @@ public:
|
||||||
/// @brief The default constructor.
|
/// @brief The default constructor.
|
||||||
ObjFileParser();
|
ObjFileParser();
|
||||||
/// @brief Constructor with data array.
|
/// @brief Constructor with data array.
|
||||||
ObjFileParser( IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, const std::string &originalObjFileName);
|
ObjFileParser(IOStreamBuffer<char> &streamBuffer, const std::string &modelName, IOSystem* io, ProgressHandler* progress, std::string originalObjFileName);
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
~ObjFileParser();
|
~ObjFileParser();
|
||||||
/// @brief If you want to load in-core data.
|
/// @brief If you want to load in-core data.
|
||||||
|
|
|
@ -92,9 +92,8 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||||
* are applied is - as always - scaling, rotation, translation.
|
* are applied is - as always - scaling, rotation, translation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char szTemp[512];
|
int rounded;
|
||||||
int rounded = 0;
|
char szTemp[512];
|
||||||
|
|
||||||
|
|
||||||
/* Optimize the rotation angle. That's slightly difficult as
|
/* Optimize the rotation angle. That's slightly difficult as
|
||||||
* we have an inprecise floating-point number (when comparing
|
* we have an inprecise floating-point number (when comparing
|
||||||
|
@ -185,7 +184,6 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||||
info.mTranslation.y = out;
|
info.mTranslation.y = out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -428,7 +426,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||||
// at the end of the list
|
// at the end of the list
|
||||||
bool ref[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
bool ref[AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
|
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
|
||||||
ref[n] = (!mesh->mTextureCoords[n] ? true : false);
|
ref[n] = !mesh->mTextureCoords[n];
|
||||||
|
|
||||||
for (it = trafo.begin();it != trafo.end(); ++it)
|
for (it = trafo.begin();it != trafo.end(); ++it)
|
||||||
ref[(*it).uvIndex] = true;
|
ref[(*it).uvIndex] = true;
|
||||||
|
|
|
@ -285,7 +285,7 @@ public:
|
||||||
* The return value remains valid until the property is modified.
|
* The return value remains valid until the property is modified.
|
||||||
* @see GetPropertyInteger()
|
* @see GetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
const std::string GetPropertyString(const char* szName,
|
std::string GetPropertyString(const char* szName,
|
||||||
const std::string& sErrorReturn = "") const;
|
const std::string& sErrorReturn = "") const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
@ -294,7 +294,7 @@ public:
|
||||||
* The return value remains valid until the property is modified.
|
* The return value remains valid until the property is modified.
|
||||||
* @see GetPropertyInteger()
|
* @see GetPropertyInteger()
|
||||||
*/
|
*/
|
||||||
const aiMatrix4x4 GetPropertyMatrix(const char* szName,
|
aiMatrix4x4 GetPropertyMatrix(const char* szName,
|
||||||
const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
|
const aiMatrix4x4& sErrorReturn = aiMatrix4x4()) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
@ -35,7 +35,7 @@ ADD_EXECUTABLE( assimp_simpletexturedogl WIN32
|
||||||
|
|
||||||
SET_PROPERTY(TARGET assimp_simpletexturedogl PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})
|
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
|
SET_TARGET_PROPERTIES( assimp_simpletexturedogl PROPERTIES
|
||||||
OUTPUT_NAME assimp_simpletexturedogl
|
OUTPUT_NAME assimp_simpletexturedogl
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "contrib/stb_image/stb_image.h"
|
#include "contrib/stb_image/stb_image.h"
|
||||||
|
|
||||||
|
#include <locale>
|
||||||
|
#include <codecvt>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
//to map image filenames to textureIds
|
//to map image filenames to textureIds
|
||||||
|
@ -75,6 +77,36 @@ GLuint* textureIds; // pointer to texture Array
|
||||||
// Create an instance of the Importer class
|
// Create an instance of the Importer class
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
|
|
||||||
|
// Used to convert between multibyte and unicode strings.
|
||||||
|
class UTFConverter {
|
||||||
|
using UTFConverterImpl = std::wstring_convert<std::codecvt_utf8<wchar_t>, 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()
|
void createAILogger()
|
||||||
{
|
{
|
||||||
// Change this line to normal if you not want to analyse the import process
|
// 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
|
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());
|
logInfo( importer.GetErrorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -170,8 +202,21 @@ std::string getBasePath(const std::string& path)
|
||||||
return (std::string::npos == pos) ? "" : path.substr(0, pos + 1);
|
return (std::string::npos == pos) ? "" : path.substr(0, pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void freeTextureIds()
|
||||||
|
{
|
||||||
|
textureIdMap.clear(); //no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step)
|
||||||
|
|
||||||
|
if (textureIds)
|
||||||
|
{
|
||||||
|
delete[] textureIds;
|
||||||
|
textureIds = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int LoadGLTextures(const aiScene* scene)
|
int LoadGLTextures(const aiScene* scene)
|
||||||
{
|
{
|
||||||
|
freeTextureIds();
|
||||||
|
|
||||||
//ILboolean success;
|
//ILboolean success;
|
||||||
|
|
||||||
/* Before calling ilInit() version should be checked. */
|
/* Before calling ilInit() version should be checked. */
|
||||||
|
@ -205,7 +250,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int numTextures = textureIdMap.size();
|
const size_t numTextures = textureIdMap.size();
|
||||||
|
|
||||||
|
|
||||||
/* array with DevIL image IDs */
|
/* array with DevIL image IDs */
|
||||||
|
@ -217,13 +262,13 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
|
|
||||||
/* create and fill array with GL texture ids */
|
/* create and fill array with GL texture ids */
|
||||||
textureIds = new GLuint[numTextures];
|
textureIds = new GLuint[numTextures];
|
||||||
glGenTextures(numTextures, textureIds); /* Texture name generation */
|
glGenTextures(static_cast<GLsizei>(numTextures), textureIds); /* Texture name generation */
|
||||||
|
|
||||||
/* get iterator */
|
/* get iterator */
|
||||||
std::map<std::string, GLuint*>::iterator itr = textureIdMap.begin();
|
std::map<std::string, GLuint*>::iterator itr = textureIdMap.begin();
|
||||||
|
|
||||||
std::string basepath = getBasePath(modelpath);
|
std::string basepath = getBasePath(modelpath);
|
||||||
for (int i=0; i<numTextures; i++)
|
for (size_t i=0; i<numTextures; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
//save IL image ID
|
//save IL image ID
|
||||||
|
@ -268,7 +313,7 @@ int LoadGLTextures(const aiScene* scene)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Error occurred */
|
/* Error occurred */
|
||||||
MessageBox(NULL, ("Couldn't load Image: " + fileloc).c_str() , "ERROR", MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(NULL, UTFConverter("Couldn't load Image: " + fileloc).c_wstr(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
|
@ -534,31 +579,34 @@ void KillGLWindow() // Properly Kill The Window
|
||||||
{
|
{
|
||||||
if (!wglMakeCurrent(NULL, NULL)) // Are We Able To Release The DC And RC Contexts?
|
if (!wglMakeCurrent(NULL, NULL)) // Are We Able To Release The DC And RC Contexts?
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Release Of DC And RC Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
MessageBox(NULL, TEXT("Release Of DC And RC Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Release Rendering Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
MessageBox(NULL, TEXT("Release Rendering Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
}
|
}
|
||||||
hRC = NULL;
|
hRC = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hDC && !ReleaseDC(hWnd, hDC)) // Are We able to Release The DC?
|
if (hDC)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Release Device Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
if (!ReleaseDC(hWnd, hDC)) // Are We able to Release The DC?
|
||||||
hDC=NULL;
|
MessageBox(NULL, TEXT("Release Device Context Failed."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
|
hDC = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window
|
if (hWnd)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Could Not Release hWnd.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
if (!DestroyWindow(hWnd)) // Are We Able To Destroy The Window
|
||||||
|
MessageBox(NULL, TEXT("Could Not Release hWnd."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
hWnd = NULL;
|
hWnd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!UnregisterClass("OpenGL", hInstance)) // Are We Able To Unregister Class
|
if (hInstance)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Could Not Unregister Class.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
|
if (!UnregisterClass(TEXT("OpenGL"), hInstance)) // Are We Able To Unregister Class
|
||||||
|
MessageBox(NULL, TEXT("Could Not Unregister Class."), TEXT("SHUTDOWN ERROR"), MB_OK | MB_ICONINFORMATION);
|
||||||
hInstance = NULL;
|
hInstance = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,7 +614,7 @@ void KillGLWindow() // Properly Kill The Window
|
||||||
GLboolean abortGLInit(const char* abortMessage)
|
GLboolean abortGLInit(const char* abortMessage)
|
||||||
{
|
{
|
||||||
KillGLWindow(); // Reset Display
|
KillGLWindow(); // Reset Display
|
||||||
MessageBox(NULL, abortMessage, "ERROR", MB_OK|MB_ICONEXCLAMATION);
|
MessageBox(NULL, UTFConverter(abortMessage).c_wstr(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION);
|
||||||
return FALSE; // quit and return False
|
return FALSE; // quit and return False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,11 +642,11 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load the default arrow
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load the default arrow
|
||||||
wc.hbrBackground= NULL; // No Background required for OpenGL
|
wc.hbrBackground= NULL; // No Background required for OpenGL
|
||||||
wc.lpszMenuName = NULL; // No Menu
|
wc.lpszMenuName = NULL; // No Menu
|
||||||
wc.lpszClassName= "OpenGL"; // Class Name
|
wc.lpszClassName= TEXT("OpenGL"); // Class Name
|
||||||
|
|
||||||
if (!RegisterClass(&wc))
|
if (!RegisterClass(&wc))
|
||||||
{
|
{
|
||||||
MessageBox(NULL, "Failed to register the window class", "ERROR", MB_OK | MB_ICONEXCLAMATION);
|
MessageBox(NULL, TEXT("Failed to register the window class"), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION);
|
||||||
return FALSE; //exit and return false
|
return FALSE; //exit and return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,14 +664,14 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
|
||||||
{
|
{
|
||||||
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
// If The Mode Fails, Offer Two Options. Quit Or Run In A Window.
|
||||||
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
if (MessageBox(NULL,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
|
||||||
{
|
{
|
||||||
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Popup Messagebox: Closing
|
//Popup Messagebox: Closing
|
||||||
MessageBox(NULL, "Program will close now.", "ERROR", MB_OK|MB_ICONSTOP);
|
MessageBox(NULL, TEXT("Program will close now."), TEXT("ERROR"), MB_OK|MB_ICONSTOP);
|
||||||
return FALSE; //exit, return false
|
return FALSE; //exit, return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,8 +692,8 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requestes Size
|
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requestes Size
|
||||||
|
|
||||||
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
|
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
|
||||||
"OpenGL", // Class Name
|
TEXT("OpenGL"), // Class Name
|
||||||
title, // Window Title
|
UTFConverter(title).c_wstr(), // Window Title
|
||||||
WS_CLIPSIBLINGS | // Required Window Style
|
WS_CLIPSIBLINGS | // Required Window Style
|
||||||
WS_CLIPCHILDREN | // Required Window Style
|
WS_CLIPCHILDREN | // Required Window Style
|
||||||
dwStyle, // Selected WIndow Style
|
dwStyle, // Selected WIndow Style
|
||||||
|
@ -729,6 +777,16 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cleanup()
|
||||||
|
{
|
||||||
|
freeTextureIds();
|
||||||
|
|
||||||
|
destroyAILogger();
|
||||||
|
|
||||||
|
if (hWnd)
|
||||||
|
KillGLWindow();
|
||||||
|
};
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window
|
LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window
|
||||||
UINT uMsg, // Message for this Window
|
UINT uMsg, // Message for this Window
|
||||||
WPARAM wParam, // additional message Info
|
WPARAM wParam, // additional message Info
|
||||||
|
@ -807,20 +865,25 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
||||||
if (argv != NULL && argc > 1)
|
if (argv != NULL && argc > 1)
|
||||||
{
|
{
|
||||||
std::wstring modelpathW(argv[1]);
|
std::wstring modelpathW(argv[1]);
|
||||||
modelpath = std::string(modelpathW.begin(), modelpathW.end());
|
modelpath = UTFConverter(modelpathW).str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Import3DFromFile(modelpath)) return 0;
|
if (!Import3DFromFile(modelpath))
|
||||||
|
{
|
||||||
|
cleanup();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
logInfo("=============== Post Import ====================");
|
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;
|
fullscreen=FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CreateGLWindow(windowTitle, 640, 480, 16, fullscreen))
|
if (!CreateGLWindow(windowTitle, 640, 480, 16, fullscreen))
|
||||||
{
|
{
|
||||||
|
cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,6 +924,7 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
||||||
fullscreen=!fullscreen;
|
fullscreen=!fullscreen;
|
||||||
if (!CreateGLWindow(windowTitle, 640, 480, 16, fullscreen))
|
if (!CreateGLWindow(windowTitle, 640, 480, 16, fullscreen))
|
||||||
{
|
{
|
||||||
|
cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,18 +932,6 @@ int WINAPI WinMain( HINSTANCE hInstance, // The instance
|
||||||
}
|
}
|
||||||
|
|
||||||
// *** cleanup ***
|
// *** cleanup ***
|
||||||
|
cleanup();
|
||||||
textureIdMap.clear(); //no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step)
|
return static_cast<int>(msg.wParam);
|
||||||
|
|
||||||
if (textureIds)
|
|
||||||
{
|
|
||||||
delete[] textureIds;
|
|
||||||
textureIds = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// *** cleanup end ***
|
|
||||||
|
|
||||||
destroyAILogger();
|
|
||||||
KillGLWindow();
|
|
||||||
return (msg.wParam);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue