Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

c++ - OpenGL: glGetError() returns invalid enum after call to glewInit()

I use GLEW and freeglut. For some reason, after a call to glewInit(), glGetError() returns error code 1280, even with glewExperimental = GL_FALSE.

I cannot compile the shaders, glGetProgramInfoLog() returns "Vertex shader(s) were not successfully compiled before glLinkProgram() was called. Link failed." I was able to compile the shaders before.

Reinstalling the drivers didn't help.

Here's my code:

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
", 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.
");
        exit(EXIT_FAILURE);
    }

    glutReshapeFunc(ResizeFunction);
    glutDisplayFunc(RenderFunction);
    glutIdleFunc(IdleFunction);
    glutTimerFunc(0, TimerFunction, 0);
    glutCloseFunc(Cleanup);
    glutKeyboardFunc(KeyboardFunction);
}

What I am doing wrong?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Did you see the comment on this wiki page?

http://www.opengl.org/wiki/OpenGL_Loading_Library

It mentions why this occurs, and it says "in some cases you may still get GL_INVALID_ENUM after specifying glewExperimental depending on your glew version".

It sounds like it might be safe to ignore as long as you're not seeing any other problems.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...