I’ve been looking over the OpenGL interoperability section of the CUDA Programming Guide for CUDA 4.0, and have a few questions; specifically, in section 220.127.116.11 (OpenGL Interoperability), there’s a small code sample demonstrating the use of a cuda kernel to “dynamically modify a 2D width x height grid of vertices stored in a vertex buffer object”. My question centers around the following excerpt from the code section:
// Create buffer object and register it with CUDA glGenBuffers(1, positionsVBO); glBindBuffer(GL_ARRAY_BUFFER, &vbo); unsigned int size = width * height * 4 * sizeof(float); glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); cuGraphicsGLRegisterBuffer(&positionsVBO_CUDA, positionsVBO, cudaGraphicsMapFlagsWriteDiscard);
This is the first (and only) reference to the “vbo” variable; is this a typo, and it should instead be positionsVBO, or should it indeed be a completely different GLuint variable?
Also, what does the second call to “glBindBuffer” do? Is it for the 2nd buffer used in double buffering?
I have next to no experience with OpenGL, so I apologize ahead of time if these questions are nonsensical.