(1)glGetUniformLocation 报错:invalid operator 时,除了常规的program相关错误外,注意shader是否有错误
(2)万恶的GLSL,由于in 的变量是只读的,我在shader里对in的变量进行更改,导致无名错误调试了好久。FUCK~
(3)又是Shader出的问题,当一个uniform 变量同shader最终的输出没有任何关系时,编译器会将该变量优化掉,这样就无法提供该变量的location,
导致glGetUniformLocation函数返回-1
(4)
d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C2144: syntax error : 'void' should be preceded by ';' d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C2146: syntax error : missing ';' before identifier 'glAccum' d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C2182: 'APIENTRY' : illegal use of type 'void' d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1152) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1153) : error C2144: syntax error : 'void' should be preceded by ';' d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1153) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int d:\programs\microsoft visual studio 8\vc\platformsdk\include\gl\gl.h(1172) : error C2182: 'APIENTRY' : illegal use of type 'void'
类似与这种错误,可能原因是头文件的问题,如果图像界面使用的是windows那一套的,解决方法:在opengl头文件前加
#include<windows.h> #pragma comment(lib, "opengl32.lib")
建议lib显示链接,这样可以免去在代码移植时,配置库的麻烦
如果使用的是类似glut的头文件,opengl头文件最好放在系统头文件之后
#include <GL/glew.h> #include <GL/freeglut.h> #pragma comment(lib,"freeglut.lib") #pragma comment(lib,"glew32.lib")