Marco
Marco

Reputation: 339

glBindBuffer gives error 502 GL_INVALID_OPERATION

executing the following code

int object::draw(){

glBindBuffer(GL_ARRAY_BUFFER, vbobuffer);
if(myglError("glBindBuffer in object.draw")){
    //return 0;
}

glDrawArrays(GL_TRIANGLES, 0, buffer_size);
if(myglError("glDrawArrays in object.draw")){
    return 0;
}

return 1;
}

where

inline int myglError(const char* location) {
GLenum error = GL_NO_ERROR;
error = glGetError();
if (GL_NO_ERROR != error) {
    printf("GL Error %x encountered in %s.\n", error, location);
    //exit(-1);
    return 1;
}
return 0;
}

I get the output GL Error 502 encountered in glBindBuffer in object.draw.

However glDrawArrays still draws the triangles.

By checking the documentation http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml glBindBuffer can return GL_INVALID_ENUM or GL_INVALID_VALUE... but there is no information about glBindBuffer giving GL_INVALID_OPERATION

What is going on here?

Upvotes: 2

Views: 8440

Answers (1)

Marco
Marco

Reputation: 339

I did not read the glGetError carefully and I overlooked how the glGetError works. It just reports all the errors occured since last glGetError call and not just the status after a gl function call.

Upvotes: 1

Related Questions