tjenks
tjenks

Reputation: 236

Is it possible to retrieve a pixel buffer when setup using the cuda_gl_interop functions?

I have read around the subject and am in the process of implementing a parallelized raytracing engine (currently using ray-sphere intersections only) however it seems I can only display my results in a GLUT window or directly write to file, not both. I am at a loss as to how this could be achieved. I am currently setting up a cudaGraphicsResource and mapping it to a GL pixel buffer object. Being relatively inexperienced with OpenGL, I was not sure how one would go about retrieving the pixel data back on the CPU.

EDIT: Sorry. As I posted, I found the blindingly obvious glReadPixels routine. Will look into that.

Upvotes: 0

Views: 75

Answers (1)

tjenks
tjenks

Reputation: 236

I found that the fact the pixel buffer object was referenced to the CUDA code was irrelevant. It was simple enough to simply make a glReadPixels(0,0,DIM,DIM,GL_RBGA,GL_UNSIGNED_BYTE,&bucketofdata) call. The trouble I had which I still have not completely answered to myself is why the above call would fail if bucketofdata is initialised using malloc and only works if it is declared as GLubyte bucketofdata[DIM*DIM*sizeof(uchar4)].

Upvotes: 1

Related Questions