I am getting this compilation error:
Error: 'Transform': 'class' OpenGL 3D type redefinition on line 5
Here is my Transform.h:
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
class Transform
{
public:
Transform(const glm::vec3& pos = glm::vec3(), const glm::vec3& rot = glm::vec3(), const glm::vec3& scale = glm::vec3(1.0f, 1.0f, 1.0f)) :
Pos(pos),
Rot(rot),
Scale(scale) {}
inline glm::mat4 GetModel() const
{
glm::mat4 posMatrix = glm::translate(Pos);
glm::mat4 rotXMatrix = glm::rotate(Rot.x, glm::vec3(1,0,0));
glm::mat4 rotYMatrix = glm::rotate(Rot.y, glm::vec3(0,1,0));
glm::mat4 rotZMatrix = glm::rotate(Rot.z, glm::vec3(1,0,0));
glm::mat4 scaleMatrix = glm::scale(Scale);
glm::mat4 rotMatrix = rotZMatrix * rotYMatrix * rotXMatrix;
return posMatrix * rotMatrix * scaleMatrix;
}
inline glm::vec3& GetPos() { return Pos; }
inline glm::vec3& GetRot() { return Rot; }
inline glm::vec3& GetScale() { return Scale; }
inline void SetPos(glm::vec3& pos) { Pos = pos; }
inline void SetRot(glm::vec3& rot) { Rot = rot; }
inline void SetScale(glm::vec3& scale) { Scale = scale; }
protected:
private:
glm::vec3 Pos;
glm::vec3 Rot;
glm::vec3 Scale;
};
I am following this tutorial series from thebennybox:
https://www.youtube.com/watch?v=Xe7FmplKAF0&t=419s
I am using Visual Studio Community 2015 with C++ and OpenGL.
What is causing that error, and how can I solve it?
You to add an include guard to your header file. Check this link : cplusplus.com/forum/general/71787