Mac Big Sur C++ OpenGL attempting to learn quaternions from a tutorial.
The gtx headers are under usr/local/include/glm
.
Can anyone figure out what is wrong with my header includes or header search path? Thanks.
Minimum reproducible code that fails for this issue:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h> // for window and keyboard
#include <iostream>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
int main ( void )
{
float t =1.0;
// http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/
glm::vec3 RotationAxis(0.0f,1.0f,0.0f);
float RotationAngle = 90 * t;
glm::quat MyQuaternion;
MyQuaternion = gtx::quaternion::angleAxis(glm::degrees(RotationAngle), RotationAxis);
return 0;
}
The build error:
Use of undeclared identifier 'gtx'
which occurs on the line with gtx
.
My Build Phases / Header Search Paths / Debug / Any Architecture:
/usr/local/include
/usr/local/include/glm
/usr/local/include/glm/gtx
/usr/local/Cellar
/glew/2.2.0_1/include/GL
/usr/local/Cellar
/glfw/3.3.4/include/GLFW
/usr/local/include/glad/include
My Library Search Paths: $(inherited) /usr/local/Cellar/glew/2.2.0_1/lib /usr/local/Cellar/glfw/3.3.4/lib /usr/local/include /usr/local/include/glad/include
In tutorial 1 of the link in the comment, the author introduces
using namespace glm;
which I assume they expect you to use throughout the tutorials.
The namespace that you want to look into is not just gtx
, but glm::gtx
, so without the using namespace
you need to fully qualify it:
MyQuaternion = glm::gtx::quaternion::angleAxis(glm::degrees(RotationAngle), RotationAxis);
However, the tutorial seems to be rather old. As far as I can tell, the entities it uses from the glm::gtx::quaternion
namespace have been moved to the glm
namespace many years ago, see github commit.
So, without knowing whether anything else changed about these functions, it seems you should replace gtx::quaternion
with glm
in the code from your question and the tutorial.