I use visual studio to do load a 3D model with opengl and Assimp, so I imported Assimp in my project without any problem. I want to make a class called "Model" that can load a 3D model from a file (I am following the tutorial from learnopengl.com), but visual studio 2019 says "; expected" at some point :
#pragma once
#include "Shader.h";
#include "Mesh.h";
#include <Importer.hpp>
#include <scene.h>
#include <postprocess.h>
class Model
{
public:
/* Functions */
Model(char* path)
{
loadModel(path);
}
void Draw(Shader shader);
private:
/* Model Data */
vector<Mesh> meshes;
string directory;
/* Functions */
void loadModel(string path);
void processNode(aiNode* node, const aiScene* scene);
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
vector<Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type,
string typeName);
};
void Model::loadModel(string path)
{
Assimp::Importer imp; // "; expected"
int a; //works fine
Shader shader("test", "test"); //works fine
}
Look at the "load model" function, visual studio says "; expected" and the imp variable is highlighted in red. I am following this tutorial : https://learnopengl.com/Model-Loading/Model
Update :
#pragma once
#include <Importer.hpp>
class test
{
void f();
};
void test::f()
{
Assimp::Importer imp();// "; expected"
}
Same error here
UPDATE 2 : Now it works but I don't understand why I had an include folder with all my assimp include files inside, and my visual studio project add linked all include file by linking my folder named "include". So I was linking $(SolutionDir/ExternalLibs/assimp/include)
But for some reason, after hours of trying to figure out the problem, I panicked and created a file named "assimp" inside my include folder, then I put all my include files from the assimp library inside my new folder. So my path to my include files is now "ExternalLibs/assimp/include/assimp"
And now it works, I don't know why. I include like this :
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
Instead of this :
#include <Importer.hpp>
#include <scene.h>
#include <postprocess.h>
I don't know why it works, because firstly, every tutorial I have seen doesnt do that, AND before anyway I could instantiate other object specific to this library (aiNode, aiMesh, aiScene like you can see in my code) without any problem. Even inside a function, like for the Assimp::Importer.
So now I don't have the "; expected" error. I guess its a bug, and I don't know if it comes from the library or visual studio