编译时出现 GL3W 错误

GL3W error on compilation

我正在尝试使用 gl3w 静态编译 opengl 程序,但在执行 g++ -Wall -o Code Code.cpp --static -ldl -lc -lglut -lGL -lGLU

时出现以下错误
Code.cpp: In function ‘void drawScene()’:
Code.cpp:148:15: error: ‘GL_MODELVIEW’ was not declared in this scope
Code.cpp:148:27: error: ‘glMatrixMode’ was not declared in this scope
Code.cpp:149:17: error: ‘glLoadIdentity’ was not declared in this scope
Code.cpp:150:15: error: ‘glPushMatrix’ was not declared in this scope
Code.cpp:155:32: error: ‘glTranslatef’ was not declared in this scope
Code.cpp:156:27: error: ‘glScalef’ was not declared in this scope
Code.cpp:157:28: error: ‘glColor3f’ was not declared in this scope
Code.cpp:167:34: error: ‘glRasterPos3f’ was not declared in this scope
Code.cpp:172:15: error: ‘glPopMatrix’ was not declared in this scope
Code.cpp:210:19: error: ‘glBegin’ was not declared in this scope
Code.cpp:211:29: error: ‘glVertex3f’ was not declared in this scope
Code.cpp:215:9: error: ‘glEnd’ was not declared in this scope
Code.cpp:216:15: error: ‘glPopMatrix’ was not declared in this scope
Code.cpp:236:35: error: ‘glRotatef’ was not declared in this scope
Code.cpp:238:37: error: ‘glColor4f’ was not declared in this scope
Code.cpp:242:14: error: ‘glPopMatrix’ was not declared in this scope
Code.cpp:249:34: error: ‘glColor4f’ was not declared in this scope
Code.cpp:253:18: error: ‘glBegin’ was not declared in this scope
Code.cpp:254:29: error: ‘glVertex3f’ was not declared in this scope
Code.cpp:260:33: error: ‘glColor4f’ was not declared in this scope
Code.cpp:274:8: error: ‘glEnd’ was not declared in this scope
Code.cpp:282:34: error: ‘glColor4f’ was not declared in this scope
Code.cpp:299:34: error: ‘glColor4f’ was not declared in this scope
Code.cpp:323:19: error: ‘glVertex2f’ was not declared in this scope
Code.cpp: In function ‘void drawBox(float)’:
Code.cpp:693:18: error: ‘glBegin’ was not declared in this scope
Code.cpp:694:31: error: ‘glVertex2f’ was not declared in this scope
Code.cpp:698:8: error: ‘glEnd’ was not declared in this scope
Code.cpp:702:37: error: ‘glVertex3f’ was not declared in this scope
Code.cpp: In function ‘void drawLaser(int)’:
Code.cpp:713:28: error: ‘glColor3f’ was not declared in this scope
Code.cpp:714:18: error: ‘glBegin’ was not declared in this scope
Code.cpp:715:30: error: ‘glVertex2f’ was not declared in this scope
Code.cpp:717:8: error: ‘glEnd’ was not declared in this scope
Code.cpp: In function ‘void drawCannon()’:
Code.cpp:723:18: error: ‘glBegin’ was not declared in this scope
Code.cpp:725:30: error: ‘glVertex3f’ was not declared in this scope
Code.cpp:730:8: error: ‘glEnd’ was not declared in this scope
Code.cpp:746:28: error: ‘glColor3f’ was not declared in this scope
Code.cpp: In function ‘void drawSpider(float)’:
Code.cpp:776:25: error: ‘glBegin’ was not declared in this scope
Code.cpp:778:58: error: ‘glVertex2f’ was not declared in this scope
Code.cpp:780:8: error: ‘glEnd’ was not declared in this scope
Code.cpp:784:30: error: ‘glVertex3f’ was not declared in this scope
Code.cpp: In function ‘void initRendering()’:
Code.cpp:822:11: error: ‘GL_COLOR_MATERIAL’ was not declared in this scope
Code.cpp: In function ‘void handleResize(int, int)’:
Code.cpp:830:15: error: ‘GL_PROJECTION’ was not declared in this scope
Code.cpp:830:28: error: ‘glMatrixMode’ was not declared in this scope
Code.cpp:831:17: error: ‘glLoadIdentity’ was not declared in this scope
Code.cpp:833:15: error: ‘GL_MODELVIEW’ was not declared in this scope
Code.cpp: In function ‘void GetOGLPos(int, int)’:
Code.cpp:940:16: error: ‘GL_MODELVIEW_MATRIX’ was not declared in this scope
Code.cpp:941:16: error: ‘GL_PROJECTION_MATRIX’ was not declared in this scope

我在#include "GL/glut.h" 之前包含了#include "GL/gl3w.h" 并且还在 /usr/include/GL/ 文件夹中添加了 gl3w.h。他们是不是我做错了什么?

您尝试使用的函数(例如,glBegin()glVertex…() 等)是 OpenGL 兼容性配置文件的一部分。它们不存在于 gl3w 提供的 OpenGL 核心配置文件中。

听起来这可能不是您真正想要的。如果是这样,请不要使用 gl3w。