Fixed SimpleTexturedDirectX11 sample.
- Removed OpenGL/Glut references in SimpleTexturedDirectX11 CMakeFile - Moved UTFConverter from SimpleTexturedOpenGL to its own file to be able to reuse it. - Added compile definition SHADER_PATH to allow to locate the shader files in CMakeFile - Fixed compile warnings - Made global pointers null to help prevent dangling references. - Added missing members initialization in class constructors. - Removed references to missing model "Models/mymodel.fbx" - Fixed error when extracting model file directory - Added missing device context assignment in ModelLoader Load method - Fixed memory leak caused by variable 'ourModel' not deleted. - Removed call to dev->Release() in ModelLoader.cpp - Adjusted Release() calls in reverse order when cleaning up D3D - Made Throwanerror implementation throw an error instead of displaying a message box - Fixed leaking D3D resources - Added a pointer to an ID3D11Debug to dump live objects.
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
#include "ModelLoader.h"
|
||||
|
||||
ModelLoader::ModelLoader()
|
||||
ModelLoader::ModelLoader() :
|
||||
dev(nullptr),
|
||||
devcon(nullptr),
|
||||
meshes(),
|
||||
directory(),
|
||||
textures_loaded(),
|
||||
hwnd(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -20,9 +26,10 @@ bool ModelLoader::Load(HWND hwnd, ID3D11Device * dev, ID3D11DeviceContext * devc
|
||||
if (pScene == NULL)
|
||||
return false;
|
||||
|
||||
this->directory = filename.substr(0, filename.find_last_of('/'));
|
||||
this->directory = filename.substr(0, filename.find_last_of("/\\"));
|
||||
|
||||
this->dev = dev;
|
||||
this->devcon = devcon;
|
||||
this->hwnd = hwnd;
|
||||
|
||||
processNode(pScene->mRootNode, pScene);
|
||||
@@ -138,12 +145,13 @@ vector<Texture> ModelLoader::loadMaterialTextures(aiMaterial * mat, aiTextureTyp
|
||||
|
||||
void ModelLoader::Close()
|
||||
{
|
||||
for (auto& t : textures_loaded)
|
||||
t.Release();
|
||||
|
||||
for (int i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
meshes[i].Close();
|
||||
}
|
||||
|
||||
dev->Release();
|
||||
}
|
||||
|
||||
void ModelLoader::processNode(aiNode * node, const aiScene * scene)
|
||||
|
||||
Reference in New Issue
Block a user