Weird GL_INVALID_OPERATION error in OpenGL

c++, opengl, opengl-3

Solution

The possible `GL_INVALID_OPERATION` errors generated by `glVertexAttribPointer()`:

`GL_INVALID_OPERATION` is generated if size is `GL_BGRA` and type is not `GL_UNSIGNED_BYTE`, `GL_INT_2_10_10_10_REV` or `GL_UNSIGNED_INT_2_10_10_10_REV`.

`GL_INVALID_OPERATION` is generated if type is `GL_INT_2_10_10_10_REV` or `GL_UNSIGNED_INT_2_10_10_10_REV` and size is not 4 or `GL_BGRA`.

`GL_INVALID_OPERATION` is generated if type is `GL_UNSIGNED_INT_10F_11F_11F_REV` and size is not 3.

`GL_INVALID_OPERATION` is generated by `glVertexAttribPointer` if size is `GL_BGRA` and noramlized is `GL_FALSE`.

`GL_INVALID_OPERATION` is generated if zero is bound to the `GL_ARRAY_BUFFER` buffer object binding point and the pointer argument is not `NULL`.

http://www.opengl.org/sdk/docs/man/xhtml/glVertexAttribPointer.xml

Problem

``` glClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); AttachVertexShader( shader, "szescian_vs.glsl" ); AttachFragmentShader( shader, "szescian_fs.glsl" ); LinkProgram( shader ); glBindVertexArray( vertexVAO ); glGenBuffers( 1, &positionBuffer ); glGenBuffers( 1, &positionBuffer ); glBindBuffer( GL_ARRAY_BUFFER, positionBuffer ); glBufferData( GL_ARRAY_BUFFER, sizeof( position ), position, GL_STATIC_DRAW ); positionLoc = glGetAttribLocation( shader, "inPosition" ); glEnableVertexAttribArray ( positionLoc ); glVertexAttribPointer ( positionLoc, 3, GL_FLOAT, GL_FALSE, 0, ( void* ) 0 ); //here gDEBugger GL breaks on OpenGL Error ``` It's part of my init function, and I really don't know why gDEBugger breaks on it, can anybody explain it for me? Break Reason OpenGL Error Breaked-on glVertexAttribPointer(0 , 3 , GL_FLOAT , FALSE , 0 , 0x00000000) Error-Code GL_INVALID_OPERATION Error-Description The specified operation is not allowed in the current state. The offending function is ignored, having no side effect other than to set the error flag. * Stopped before function execution This is break information.

Original source