Results 1 to 4 of 4

Thread: Data in VBO is getting corrupted

  1. #1
    Newbie Newbie
    Join Date
    Apr 2017
    Posts
    3

    Data in VBO is getting corrupted

    Hello, I'm currently working on an engine, and I've come upon a strange issue where data in my vertex buffer gets corrupted (filled with NaN, nulled) upon posting that data with glVertexAttribPointer

    I use the following code to retrieve the data, each time (except slightly adjusted due to the different scopes)

    Code :
        glGetBufferSubData(GL_ARRAY_BUFFER,0,Data3D.size() * sizeof(glm::vec3), &vertices);
        for (int i = 0; i < Data3D.size(); i++)
        {
            std::cout << vertices[i] << std::endl;
        }

    The first time, it outputs this:
    6236a9fdb1a35e56e33dcaedf87bb935.jpg

    Right after the glBufferData call, it clearly shows that the data has been uploaded correctly (even if that is a small snippet of the vertices)

    Right before, and after i call glVertexAttribPointer, I get something completely different, however.894b9733d735accb7329c10da2cee22c.jpg


    As you can see, the data in my VBO has become corrupted, and therefore, upon calling glDrawArrays, it completely breaks, and throws a segmentation fault.

    Can I have some insight into why my vertex data would randomly corrupt itself?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,650
    Quote Originally Posted by Atemboi View Post
    As you can see, the data in my VBO has become corrupted...
    Either that, or you're not querying the contents of the VBO properly in the second and subsequent queries.

    Are you sure you're binding the buffer before calling glGetBufferSubData? Are you sure that same buffer handle is not being bound elsewhere when you are uploading content for a new buffer object?

    You might post a bit more code.

  3. #3
    Newbie OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,789
    Also, what data type is your "vertices" variable? The rest of your code inclines me to think it might be a std::vector, which is certainly not correct usage. Even if a pointer or array it's still not correct to use the address-of operator on it, so yeah, you really need to show more code because you're clearly doing something wrong.

  4. #4
    Newbie Newbie
    Join Date
    Apr 2017
    Posts
    3
    Hey, Vertices was just a vector of type glm::vec3.

    I managed to fix it, somewhere along the line, a stray glBufferSubData call came up, which bound incorrect data to my VBO.

    Thanks for the help though, guys.

Similar Threads

  1. Corrupted data during mapped buffer! (Uniform Buffer Objects)
    By FrankBoltzmann in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 06-24-2014, 03:15 AM
  2. ATI: Corrupted data when using 3D textures
    By Jan in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 01-06-2011, 03:13 AM
  3. VBO - index data gets corrupted
    By arabesc in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 05-28-2009, 02:22 PM
  4. Corrupted faces
    By michael roebbeling in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-14-2005, 10:22 AM
  5. CORRUPTED PAK0.pk3!!!!!
    By rj65 in forum OpenGL: User Software
    Replies: 0
    Last Post: 09-08-2002, 11:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean