PDA

View Full Version : VBO and error 1282



superseed77
08-07-2014, 08:24 AM
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

mhagain
08-07-2014, 01:14 PM
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).

superseed77
08-08-2014, 05:51 AM
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

mhagain
08-08-2014, 12:22 PM
You mean like this ?

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]));

superseed77
08-11-2014, 05:11 AM
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 ..

Yandersen
08-11-2014, 02:43 PM
Unless you're using VAOs (which it doesn't look like you are) you should...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.