Draw pixelarray from gpu directly to screen (Open GL) [solved]

Hi,

an one-dimensional integer array on the gpu is filled by the CUDA kernel.
The length of the array is the size of my draw area(e.g. 800 * 600).
Each integer value of the array contains the rgb data at the given index.
How can I draw this array without copying it back to cpu to screen?
I’ve heard about OpenGL and PixelBufferObjects but I am really not familiar with that.
Can anyone point me into the right direction?

Thanks, Kodex

may be worth a look:

[url]Page Not Found | NVIDIA

@Kodex,

I put together a small CUDA+GLFW interop example and left it here:

Replace the kernel.cu code with your own.

FWIW, there is frustratingly little CUDA interop documentation made worse by plenty of rotting code in the CUDA Toolkit Samples.

NVIDIA has published one new example outside of the CUDA Toolkit:

Unfortunately, this “bind once” tip didn’t seem to work for me with CUDA surfaces and multiple GPUs but the author seems confident.

Good luck!

@allanmac,

tried to use your code sample in my VisualStudio 2013 CUDA project but unfortunately it does not know surf2Dwrite() although I did include the necessary headers. Any idea whats wrong with VS?

@txbob,

I read through the paper and created a sample project that does work more or less. I can post the code if wished.

The surf2DWrite() function is part of the CUDA API and as long as your kernel is in a .cu file then VS should compile it.

This might help: Includes for surf2Dwrite()???

Finally I got sufr2Dwrite running after a CUDA and VisualStudio reinstallation in a new project.
Don’t know what went wrong.

@allanmac,
your code works fine now.

Thanks to all for the help!