Hi everybody!
Sorry if this topic has been discussed but I did not find anything External Image
My problem is simple. I have an image stored in and array of float, I mean
float4 image
I want to display it using OpenGl interop, how can I achieve this? I tried with:
cudaGraphicsMapResources(1, &pboCUDA, 0);
size_t num_bytes;
cudaGraphicsResourceGetMappedPointer((void**)&image, &num_bytes, pboCUDA);
kernel<<<g1,b1>>>(image, ...);
cudaGraphicsUnmapResources(1, &pboCUDA, 0);
and the init code
GLuint pbo;
struct cudaGraphicsResource* pboCUDA;
glGenBuffers(1, &pbo);
glBindBuffer(GL_ARRAY_BUFFER, pbo);
unsigned int size = width* height * 4 * sizeof(float);
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
cudaGraphicsGLRegisterBuffer(&pboCUDA, pbo, cudaGraphicsMapFlagsWriteDiscard);
drawing code
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindBuffer(GL_ARRAY_BUFFER, pbo);
glVertexPointer(4, GL_FLOAT, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_POINTS, 0, width* height);
glDisableClientState(GL_VERTEX_ARRAY);
but I found an error trying to register de cudaGraphicsResource…do you know how I can simply display the image?
Because I found that OpenGLs primitives are not fast…
Thank you very much