Edited: added Shader class.
I'm writing a DLL library but MS VS intellisense and compiler complaining about Mesh constructor. If i change Material attribute in Mesh constructor to Texture all OK. I tried to change struct to class, but it doesnt worked. Deleting FFB_FRAMEWORK_API marcro doesnt worked too.
DataStrictures.h
struct Vertex {
// position
glm::vec3 Position;
// normal
glm::vec3 Normal;
// texCoords
glm::vec2 TexCoords;
// tangent
glm::vec3 Tangent;
// bitangent
glm::vec3 Bitangent;
};
struct Texture
{
unsigned int id;
std::string type;
};
main.h
#ifdef FFB_FRAMEWORK_EXPORTS
#define FFB_FRAMEWORK_API __declspec(dllexport)
#else
#define FFB_FRAMEWORK_API __declspec(dllimport)
#endif
class FFB_FRAMEWORK_API Shader
{
public:
unsigned int ID;
// constructor generates the shader on the fly
Shader(const char* vertexPath, const char* fragmentPath, const char* geometryPath = nullptr);
// activate the shader
void use();
// utility uniform functions
void setBool(const std::string &name, bool value) const;
void setInt(const std::string &name, int value) const;
void setFloat(const std::string &name, float value) const;
void setVec2(const std::string &name, const glm::vec2 &value) const;
void setVec2(const std::string &name, float x, float y) const;
void setVec3(const std::string &name, const glm::vec3 &value) const;
void setVec3(const std::string &name, float x, float y, float z) const;
void setVec4(const std::string &name, const glm::vec4 &value) const;
void setVec4(const std::string &name, float x, float y, float z, float w);
void setMat2(const std::string &name, const glm::mat2 &mat) const;
void setMat3(const std::string &name, const glm::mat3 &mat) const;
void setMat4(const std::string &name, const glm::mat4 &mat) const;
private:
// utility function for checking shader compilation/linking errors.
void checkCompileErrors(GLuint shader, std::string type);
};
struct FFB_FRAMEWORK_API Material
{
Shader shader;
std::vector<Texture> textures;
};
class FFB_FRAMEWORK_API Mesh
{
private:
std::vector<Vertex> m_vertices;
std::vector<unsigned int> m_indices;
Material m_material;
unsigned int VAO, VBO, EBO;
void SetupMesh();
public:
Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, Material material);
void Draw(Shader shader);
};
Mesh.h
Mesh::Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, Material material)
{
m_vertices = vertices;
m_indices = indices;
m_material = material;
// now that we have all the required data, set the vertex buffers and its attribute pointers.
SetupMesh();
}
Compiler complaining right before m_verticies = vertices
Severity Code Description Project File Line Suppression State Error (active) E1790 the default constructor of "Framework::Graphics::Material" cannot be referenced -- it is a deleted function FFB_Framework c:\Users\User\Documents\Visual Studio 2017\Projects\FFB\FFB_Framework\Mesh.cpp 7
Edited. If i changing constructor to
Mesh::Mesh(std::vector<Vertex> vertices, std::vector<unsigned int> indices, Material material):m_vertices(vertices),m_indices(indices),m_material(material)
{SetupMesh();}
Compiler throw that errors:
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl Framework::Graphics::Material::~Material(void)" (__imp_??1Material@Graphics@Framework@@QEAA@XZ) referenced in function "public: __cdecl Framework::Graphics::Mesh::Mesh(class std::vector >,class std::vector >,struct Framework::Graphics::Material)" (??0Mesh@Graphics@Framework@@QEAA@V?$vector@UVertex@@V?$allocator@UVertex@@@std@@@std@@V?$vector@IV?$allocator@I@std@@@4@UMaterial@12@@Z) FFB_Framework C:\Users\Anton\Documents\Visual Studio 2017\Projects\FFB\FFB_Framework\Mesh.obj 1
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl Framework::Graphics::Material::Material(struct Framework::Graphics::Material const &)" (__imp_??0Material@Graphics@Framework@@QEAA@AEBU012@@Z) referenced in function "public: __cdecl Framework::Graphics::Mesh::Mesh(class std::vector >,class std::vector >,struct Framework::Graphics::Material)" (??0Mesh@Graphics@Framework@@QEAA@V?$vector@UVertex@@V?$allocator@UVertex@@@std@@@std@@V?$vector@IV?$allocator@I@std@@@4@UMaterial@12@@Z) FFB_Framework C:\Users\Anton\Documents\Visual Studio 2017\Projects\FFB\FFB_Framework\Mesh.obj 1
Does anyone know where error?
Mesh::MeshtakesMaterialby value (makes a copy) andShader shader;(member ofMaterial) is not copyable. Whats the definition ofShader? - Richard Critten