How to do openGL interop + zero copy ?

I have big cuda kernel which uses zero copy to write results data … basically ( x , y , z ) positions. I would like to plots these positions using openGL iterop.

I saw that you need to call the function " cudaGLSetGLDevice() " function for OPENGL interop. But if I call that function then how can I enable zero-copy which is done by the function :
" cudaSetDeviceFlags(cudaDeviceMapHost) "

can I call this function after " cudaGLSetGLDevice() " ? I thought you need to call cudaSetDevice() first … which I cannot as I want to use opengl Interop.


Thanks for helping.