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)

    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:

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.[ATTACH=CONFIG]1454[/ATTACH]

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?

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.

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.

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.