Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: VBO and error 1282

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    6

    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

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,680
    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).

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    6
    Quote Originally Posted by mhagain View Post
    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

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,680
    Quote Originally Posted by superseed77 View Post
    You mean like this ?
    No, I said your glVertexAttribPointer call.

    The correct setup is:
    Code :
    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]));

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    6
    Quote Originally Posted by mhagain View Post
    The correct setup is:
    Code :
    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 ..
    Last edited by superseed77; 08-11-2014 at 04:35 AM.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Dec 2010
    Location
    Oakville, ON, CA
    Posts
    165
    Quote Originally Posted by mhagain View Post
    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... I personally had a strange program behavior configuring the vertex attributes for the default VAO.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •