VBO and error 1282

Hi all

I try to update a vbo via data texture filled with positions. The positions represent points on a smooth surface like a cloth.
The texture is updated from a fragment shader that calculates forces and points positions.

I init my vbo like that:

glGenBuffers(1, &vboID);
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW); 
glVertexAttribPointer (0, 4, GL_FLOAT, GL_FALSE, 0, 0) ;

glBindBuffer(GL_ARRAY_BUFFER, 0);

do my calculations in the shader

and copy the texture data to the vbo

glReadBuffer(GL_COLOR_ATTACHMENT0); 			
glBindBuffer(GL_PIXEL_PACK_BUFFER, vboID); 			
glReadPixels(0, 0, texture_size_x, texture_size_y, GL_RGBA, GL_FLOAT, 0); 

glReadBuffer(GL_NONE); 
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);

and try to show it … but here it’s broken

so I’m not sure of this part

glEnableVertexAttribArray (0); 
glBindBuffer(GL_ARRAY_BUFFER, vboID);

// error glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0]));

the error occurs on the draw command. error 1282 means Invalid operation.
can someone help me to find out the problem

thanks

Unless you’re using VAOs (which it doesn’t look like you are) you should move your glVertexAttribPointer call to before your glDrawElements (but after the preceding glBindBuffer).

You mean like this ?

glBindBuffer(GL_ARRAY_BUFFER, vboID);
glEnableVertexAttribArray (0); 

I still get the error uncommenting gldrawelements

No, I said your glVertexAttribPointer call.

The correct setup is:

glEnableVertexAttribArray (0);
glBindBuffer(GL_ARRAY_BUFFER, vboID);
glVertexAttribPointer (0, 4, GL_FLOAT, GL_FALSE, 0, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)indices.size(), GL_UNSIGNED_SHORT, &(indices[0]));

sorry error still occurs : at glVertexAttribPointer …

[QUOTE=mhagain;1260871]Unless you’re using VAOs (which it doesn’t look like you are) you should…[/QUOTE]I thought that one MUST have a non-zero VAO bound before any glVertexAttribPointer call is made… :confused: I personally had a strange program behavior configuring the vertex attributes for the default VAO.