Simple CUDA OpenGL interoperability

Hello,

I want to try Cuda OpenGL interop. there is a code sample in SDK but I want to create some float array on host and then put it in buffer.
I have something like this:


float points = {
30.0, 50.0,
40.0, 70.0,
50.0, 115.0,
60.0, 335.0,
70.0, 245.0,
80.0, 455.0,
90.0, 195.0,
100.0, 100.0
};


// generate a new VBO and get the associated ID
glGenBuffersARB(1, &vboId);

// bind VBO in order to use
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);

// upload data to VBO
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(points), points, GL_STATIC_DRAW_ARB);

glutMainLoop();

then I have method:
void runCuda()
{
// map OpenGL buffer object for writing from CUDA

cudaGLMapBufferObject((void**)&points, vbo);

// execute the kernel
launch_kernel(points, mesh_width, mesh_height, animTime);

// unmap buffer object
cudaGLUnmapBufferObject(vbo);

}

i try to display points with: glDrawArrays(GL_POINTS, 0, 8);
but at the best situation I only get one point displayed at position (0, 0)

can you please explain me valid workflow, like:
decalre variable on host
register buffer
put variable in baffer
transfer it to device
run kernel
transfer data from device to host

is it valid workflow? how to transfer data from host to device and device to host.

kind regards
milan

Hello,

I want to try Cuda OpenGL interop. there is a code sample in SDK but I want to create some float array on host and then put it in buffer.
I have something like this:


float points = {
30.0, 50.0,
40.0, 70.0,
50.0, 115.0,
60.0, 335.0,
70.0, 245.0,
80.0, 455.0,
90.0, 195.0,
100.0, 100.0
};


// generate a new VBO and get the associated ID
glGenBuffersARB(1, &vboId);

// bind VBO in order to use
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);

// upload data to VBO
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(points), points, GL_STATIC_DRAW_ARB);

glutMainLoop();

then I have method:
void runCuda()
{
// map OpenGL buffer object for writing from CUDA

cudaGLMapBufferObject((void**)&points, vbo);

// execute the kernel
launch_kernel(points, mesh_width, mesh_height, animTime);

// unmap buffer object
cudaGLUnmapBufferObject(vbo);

}

i try to display points with: glDrawArrays(GL_POINTS, 0, 8);
but at the best situation I only get one point displayed at position (0, 0)

can you please explain me valid workflow, like:
decalre variable on host
register buffer
put variable in baffer
transfer it to device
run kernel
transfer data from device to host

is it valid workflow? how to transfer data from host to device and device to host.

kind regards
milan