我试图使用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
我在包含“GL/glut.h”之前包含了“GL/gl3w.h”,并在/usr/include/GL/文件夹中添加了gl3w.h。他们有什么不对劲吗?
最佳答案
您试图使用的函数(例如,glBegin()
,glVertex…()
等)是OpenGL兼容性配置文件的一部分。它们不存在于OpenGL核心概要文件中,这是gl3w提供的。
听起来这可能不是你真正想要的。如果是,不要使用gl3w。