我使用 GLEW 和 freeglut。出于某种原因,在调用 glewInit() 后,glGetError() 返回错误代码 1280,即使 glewExperimental = GL_FALSE 也是如此。
我无法编译着色器,glGetProgramInfoLog() 返回“顶点着色器在调用 glLinkProgram() 之前没有成功编译。链接失败。” 我之前能够编译着色器。
重新安装驱动程序没有帮助。
这是我的代码:
int main(int argc, char* argv[])
{
GLenum GlewInitResult, res;
InitWindow(argc, argv);
res = glGetError(); // res = 0
glewExperimental = GL_TRUE;
GlewInitResult = glewInit();
fprintf(stdout, "ERROR: %s\n", glewGetErrorString(GlewInitResult)); // "No error"
res = glGetError(); // res = 1280
glutMainLoop();
exit(EXIT_SUCCESS);
}
void InitWindow(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitContextVersion(4, 0);
glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
glutInitContextProfile(GLUT_CORE_PROFILE);
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,
GLUT_ACTION_GLUTMAINLOOP_RETURNS);
glutInitWindowPosition(0, 0);
glutInitWindowSize(CurrentWidth, CurrentHeight);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
WindowHandle = glutCreateWindow(WINDOW_TITLE);
GLenum errorCheckValue = glGetError();
if (WindowHandle < 1)
{
fprintf(stderr, "ERROR: Could not create new rendering window.\n");
exit(EXIT_FAILURE);
}
glutReshapeFunc(ResizeFunction);
glutDisplayFunc(RenderFunction);
glutIdleFunc(IdleFunction);
glutTimerFunc(0, TimerFunction, 0);
glutCloseFunc(Cleanup);
glutKeyboardFunc(KeyboardFunction);
}
我做错了什么?