using openGL to create a plot (contour-like)


I have some cuda code and I would like to display the data in realtime by plotting it on the screen after each iteration. I have a large 1-dimensional array which represents a 2-dimensional array of dimensions 1024 by 1024.

I would like to plot this array on the screen, such that the color of each pixel corresponds to the value of a corresponding array element. I can confine the values of the array between 0 and 1 if necessary.

I have no experience in openGL but I looked through “” so I have a very vague idea of what is going on. If anyone could point me in the right direction I would greatly appreciate it.


You’ll have to set up interop between CUDA and OpenGL. Here’s what you probably want to do.

create a pixel buffer object (PBO) that will be the texture source
register the PBO with CUDA
for each frame:
map the PBO to CUDA
launch the kernel to process PBO memory
unmap the PBO from CUDA
update the texture associated with the PBO
draw a quad (dimensions same as the data your displaying) with the texture

I have a very ugly Win32 multiwindow app that uses cuda to generate textures for quads. It’s got some very bad windows-programming practices in it, but if you want, drop me a note and I can send the source to you (I don’t want to post it publicly due to the aforementioned ugliness).