title: Qt+CUDA+OpenGL, share CUDA context with QOpenGLContext
body: <p>I have a Qt program, which using <code>QOpenGLContext</code> for rendering.<br />
  Now I want to use <code>CUDA</code> to process image without extracting image to host.</p>
  <p>If I use <code>(QT += core gui opengl)</code>, without using <code>QOpenGLContext</code>, I will use <code>cudaGraphicsGLRegisterImage</code> and map <code>OpenGL</code> to <code>CUDA</code> and everything works fine.</p>
  <p>But, when I use <a href="https://stackoverflow.com/questions/41021681/qt-how-to-detect-which-version-of-opengl-is-being-used">qputenv(&quot;QT_OPENGL&quot;, &quot;angle&quot;);</a> (to setup <code>QOpenGLContext</code>) - even calling <code>cudaGLGetDevices(&amp;glDeviceCount, glDevices, glDeviceCount, cudaGLDeviceListAll);</code> gives rubbish - meaning the <code>CUDA</code> context not the same as <code>QOpenGLContext</code>.</p>
  <p><strong>How can I setup CUDA context to be the same as QOpenGLContext?</strong><br />
  I have read <a href="https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__CTX.html" rel="nofollow noreferrer">about CUDA context</a>, e.g <code>cuCtxCreate ( CUcontext* pctx, unsigned int  flags, CUdevice dev </code><br />
  but it seems to me, that there no such option.<br />
  <strong>Maybe there are another solution, if I have to use <code>QOpenGLContext</code>?</strong></p>