OSX OpenGL error 1280 (0x0502) with glDrawElements

Hi,
I have a peace of code who works in Windows. It’s juste a binding of a VAO and VBO and a draw call.

When I try the same code on OS X I have an OpenGL error (0x0502) juste after the call of glDrawElements.

I try to send the EBO after :

GLuint EBO;
glGenBuffers(1, &EBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_UNSIGNED_INT) * nbindices, indices, GL_STATIC_DRAW);
glDrawElements(GL_TRIANGLES, nbindices, GL_UNSIGNED_INT, (void*)0);

or during the draw call :

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDrawElements(GL_TRIANGLES, nbindices, GL_UNSIGNED_INT, indices);

I try glDrawArray with the same error. I have no more idea about this.

Regards,
Robin

glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GL_UNSIGNED_INT) * nbindices, indices, GL_STATIC_DRAW);

GL_UNSIGNED_INT is not a type, it’a value. I guess what you mean is sizeof(GLuint).

[QUOTE=robinfaury;1282671]Hi,
I have a peace of code who works in Windows. It’s juste a binding of a VAO and VBO and a draw call.

When I try the same code on OS X I have an OpenGL error (0x0502) juste after the call of glDrawElements. …

I have no more idea about this.[/QUOTE]

In addition to what Hermannicus mentioned, see:

0x0502 is GL_INVALID_OPERATION. Check the potential causes of that error listed on this web page, and see if either of them might apply in your case.

Also, are you sure it’s the glDrawElements call that’s throwing the error and not an earlier call? When you check for errors, be sure to clear out all accumulated GL errors, as shown here:

Yes I have checked my OpenGL error before and after. I try an other draw call function and it’s the same problem. A glDrawArray(GL_TRIANGLES, 0, 3) return the error.

I suppose the problem come from OSX because it’s works on Windows. Are there some knew issues ? I think a thing like the glewExperimental = GL_TRUE for core profile.

Try calling glValidateProgram() prior to the draw call. If glGetProgram(GL_VALIDATE_STATUS) is false, use getProgramInfoLog() to obtain diagnostic information.

Certain combinations of GL state can cause glDraw* functions to fail for reasons not listed in the reference page (mostly because detecting such errors is optional, because it’s expensive). Such situations include the case where the number of active samplers exceeds one of the GL_MAX_*_TEXTURE_IMAGE_UNITS limits, or two sampler uniforms of different types refer to the same texture unit.

are you sure that you’ve bound a VBO to target GL_ARRAY_BUFFER ?

@john : you’re right.
I think my VBO was correctly bind but not.
in windows glGetAttribLocation return 0 for the first one, 1 for the second… In mac it isn’t the same case. So my VBO was bind on the wrong location.