glDrawElements throws 1282 (GL_INVALID_OPERATION)

I’m trying to use EBOs but when using [icode]glDrawElements()[/icode] its giving a [icode]GL_INVALID_OPERATION[/icode]. Here’s my code.


int vaoID = glGenVertexArrays();
glBindVertexArray(vaoID);

int vboVertID = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertID);
glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0);

int vboColID = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboColID);
glBufferData(GL_ARRAY_BUFFER, colors, GL_STATIC_DRAW);
glVertexAttribPointer(1, 4, GL_FLOAT, false, 0, 0);

int eboID = glGenBuffers();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, eboID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, elements, GL_STATIC_DRAW);

glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);

exitOnGLError("Before glDrawElements");
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
exitOnGLError("After glDrawElements");

And my [icode]exitOnGLError()[/icode] method is


private void exitOnGLError(String message)
{
    int error = glGetError();
    boolean hadError = false;

    while (error != GL_NO_ERROR)
    {
        System.err.println(message + " " + GLU.gluErrorString(error));
        hadError = true;
        error = glGetError();
    }

    dispose();
    System.exit(-1);
}

I’m confused, that it is unexpected that [icode]glDrawElements()[/icode] throws [icode]GL_INVALID_OPERATION[/icode]. From the docs, I’ve found that

Can anybody please say me where I’m doing wrong?

I got it fixed. This was a driver issue and updating the driver got it right.