今天要做opengl实验
打开一个示例程序,结果编译不过。错误大概如下:
d:\vc98\include\gl\gl.h(1152) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1152) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1152) : error C2146: syntax error : missing ',' before identifier 'glAccum'
d:\vc98\include\gl\gl.h(1152) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1152) : error C2059: syntax error : ')'
d:\vc98\include\gl\gl.h(1153) : error C2054: expected '(' to follow 'WINGDIAPI'
d:\vc98\include\gl\gl.h(1153) : error C2085: 'APIENTRY' : not in formal parameter list
d:\vc98\include\gl\gl.h(1153) : error C2146: syntax error : missing ',' before identifier 'glAlphaFunc'
d:\vc98\include\gl\gl.h(1153) : error C2143: syntax error : missing ';' before '('
d:\vc98\include\gl\gl.h(1153) : error C2059: syntax error : ')'
。。。
查了好久,上网找到的说法也是乱七八糟。。。
后来终于看来这个:
#include <GL/glut.h>
#include "glee.h" // 错误,因为glut.h中含有gl.h,它与glee.h冲突
// 但是如果把两个include顺序交换,则正确
"glos.h":虽然这个也时常见到,但我也不知道它到底是什么,可能是与系统相关的各种功能,也可能只是自己编写的一个文件。我曾经看到一个glos.h头文件中只有一句#include <GL/glut.h>。
原来是头文件这块出了问题。
//#include <GL/gl.h> // The GL Header File
#include <GL/glut.h> // The GL Utility Toolkit (Glut) Header
我把第一个注释掉后,终于success!