编译时出现GL3W错误

时间:2015-01-27 23:26:17

标签: c++ c opengl glew

我正在尝试使用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”,并且还将gl3w.h添加到/ usr / include / GL /文件夹中。他们有什么不对劲吗?

1 个答案:

答案 0 :(得分:2)

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

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