2

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?

Ian Young
  • 1,712
  • 1
  • 16
  • 33

3 Answers3

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?
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • By moving the glEnable code to before glewInit(), I eliminated the error. However, the problem which led to my discovery of that error is still there: The depth buffer is not being written to. – Ian Young Dec 30 '15 at 13:55
  • 1
    @IanYoung: You can't move the `glEnable` to before glewInit; until GLEW has been initialized, that function doesn't exist. – Nicol Bolas Dec 30 '15 at 13:57
  • Well it seems to be working as it was before, but without the error. – Ian Young Dec 30 '15 at 14:03
0

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));
    }
}
Orace
  • 7,822
  • 30
  • 45
  • Yes, I'm sure. That code sample was just a small part of my rendering set up code. I error check after each gl call. all prior getError calls return GL_NO_ERROR. I'll add that I found this error while searching for a reason my rendering wasn't working at all. Upon using Nvidia Nsight, and examining the depth buffer, nothing had been written to it, which led me to error check the depth test set up in particular. – Ian Young Dec 30 '15 at 11:53
  • Have you take a look here: http://stackoverflow.com/questions/10857335/opengl-glgeterror-returns-invalid-enum-after-call-to-glewinit ? – Orace Dec 30 '15 at 13:42
  • I had considered that, which is why I call glGetError() after glewExperimental = GL_TRUE; to clear the error queue. It's definitely the glEnable(GL_DEPTH_TEST) that is causing the issue. – Ian Young Dec 30 '15 at 13:46
0

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.

L. Swifter
  • 3,179
  • 28
  • 52