I am trying to implement simple cloth simulation:
I have 2 arrays of particles (2D arrays of float4 - position and one other float for special identification). I want to bind texture to one of them and read from it (I want to read one particle position multiple times). I will write new (changed) position to the second array. Now I want to attach the second array as a VBO and use it for rendering (Opengl). Then bind the same texture to second array and write to first.
This should help me to avoid copying from GPU to CPU and back.
My biggest problem is how to create array (? cudaArray or 2D array or vertex buffer object ?) and how to copy data from CPU to GPU for initialization.
I know how to create vbo, allocate memory (glBufferData), register buffer, map resource and get pointer. But how can I bind texture to this? I only know, how to bind texture to array with pitch (cudaBindTexture2D) or to cudaArray (cudaBindTextureToArray)…
I could also create cudaArray and bind texture to it, but then I don’t know how to connect it with VBO :(
I tried to understand Fluids (OpenGL Version) from nVidia cuda SDK, but it’s complicated for me :(
Can someone help me, please?
Thanks for any advise.
//EDIT: What I have understood from that SDK example (fluids): I should have one array, which will cooperate with VBO and than copy device to device from that array to cudaArray for texture binding… Am I right? If so, can I avoid that copying somehow?