错误 CC2061:语法错误:标识符"GLUquadric"

Error CC2061: syntax error: identifier 'GLUquadric'

本文关键字:错误 GLUquadric 语法 CC2061 标识符      更新时间:2023-10-16

为什么这段代码会给我一个关于标识符GLUquadric的错误?据我所知,GLFW应该将其纳入范围。

#ifndef BALL_H
#define BALL_H
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
struct Cuboid;
struct Ball {
    glm::vec3 position;
    glm::vec3 velocity;
    float radius;
    glm::quat orientation;
    glm::vec3 angular_velocity;
    Ball(float radius);
};
void draw(const Ball& ball, GLUquadric* quadric);
void integrate(Ball& ball, float dt, const Cuboid& platform, glm::vec3 torque);
#endif

我自己想出了解决方案。似乎包含Ball.h的.cpp文件(我发布的文件)已经包含GLFW/glfw3.h但事先没有#define GLFW_INCLUDE_GLU。我通过在 .cpp 文件中添加一个定义来解决它,但我想也许我可以通过制作自己的标头来完成更好的解决方案,opengl.h

#ifndef OPENGL_H
#define OPENGL_H
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#endif

然后包括它而不是GLFW/glfw3.h.