'GL Error 1280 when enabling depth test

I'm having some problems with an opengl application I'm writing.

GLenum err = 0;
glEnable( GL_DEPTH_TEST );
err = glGetError();
if ( err != GL_NO_ERROR )
    printf( "Error: %s\n",glewGetErrorString( err ) );

The above code prints out unknown error to the console, and when I step through it, I get the 1280 code. I've checked the khronos page for glEnable and the enum is there, so why would this cause an issue? I've looked up the error code and it's for an invalid enum, but how can this be?



Solution 1:[1]

Error 0x500/1280 means GL_INVALID_ENUM, which means one of the enumerators in the function call is not allowed. Obviously, that should not happen with GL_DEPTH_TEST, which has been allowed in glEnable since OpenGL 1.0. The following are all of the possible reasons why this might happen:

  1. The error is coming from some other function. Be sure you're removed all errors from the queue before making this call. You say you already tried that; I'm just being comprehensive.
  2. Your OpenGL Loading Library is faulty. Perhaps it has given the wrong value to GL_DEPTH_TEST. The value of GL_DEPTH_TEST should be 0x0B71. Alternatively, it may have put the wrong function in glEnable. To test this, you could debug into your library's initialization function, or you could use glIntercept or a similar tool to see exactly what function is being called.
  3. Driver bug. To test this, try putting this enable (with error checking) in different places in your code. Where does it error and where does it not?

Solution 2:[2]

Are you sure that the error came from the glEnable(GL_DEPTH_TEST); call ?

You may try this:

PrintErrors();               // Test for previous error
glEnable(GL_DEPTH_TEST);
PrintErrors();

...

void PrintError() {
    GLenum err;
    for(;;) {
        err = glGetError();
        if (err == GL_NO_ERROR) break;
        printf("Error: %s\n", glewGetErrorString(err));
    }
}

Solution 3:[3]

I don't think this error comes from glEnable( GL_DEPTH_TEST );

The code 1280 means GL_INVALID_ENUM;

I've encountered this error before. In my situation, I passed a renderer_program to glEnable method by mistake. After passing a correct enum to the method, OpenGL tells no errors.

So, maybe you need to focus on other parts of your code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nicol Bolas
Solution 2 Orace
Solution 3 L. Swifter