Did any one succeed in using CUDA to change the COLOR BUFFER ARRAY of VBO. I can use VERTEX_BUFFER_ARRAY with CUDA but not COLOR_BUFFER I don’t know why that happen
For example I have N point each associated with a color
if I have vertex position only
-
I create a VBO with size: N * sizeof(float4) to store N position
-
register it with CUDA
-
copy vertex position from CUDA to VBO
-
map the buffer
-
copy from CUDA to VBO
-
unmap the buffer
-
-
render from VBO
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glColor4f(0.5, 0.6, 0.7, 1.0);
glVertexPointer(4, GL_FLOAT, sizeof(float4),0);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_POINTS, 0, N);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
I read back the render buffer to check the result and it return the color that I assigned, here is (0.5, 0.6, 0.7)
However when I want to render with my own color , I did the same step
-
I create a VBO with size: 2 * N * sizeof(float4) to store N position + N color
-
register it with CUDA
-
copy vertex position from CUDA to VBO
-
map the buffer
-
copy from CUDA to VBO: with first N * sizeof(float4) byte for Vertex, N * sizeof(float4) bytes left for color
-
unmap the buffer
-
- then I render from VBO
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexPointer(4, GL_FLOAT, sizeof(float4),0);
glColorPointer(4, GL_FLOAT, sizeof(float4), (char*) NULL + N * sizeof(float4));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glDrawArrays(GL_POINTS, 0, N);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
Then when I read back the result return 0 color. I don’t really know why that happen. A bug or I did something wrong ?
I did everything I can to see what is the problem
+I try to debug by using COLOR_BUFFER from a different regular VBO ( that is not registered with CUDA) and it produced correct color
+I also try to create a COLOR_BUFFER with CUDA registered VBO then again it failed.
+In the above example I also try to allocate Vertex data after Color data, when it read back render result, it is correct with Vertex but failed with color.
So it is likely that I can only use a regular VBO with color, but i don’t want to copy from CUDA to host, it does not make sense to me.
I don’t know if it is a bug or smth else (like unsupported features). If someone experience the same problem could you share your solution.
It seems that there’s still some inter-operation issue with OpenGL. I use CUDA 2.1 on FX 5600 with Ubuntu 8.04. Any ideas are appreciated. Thank you