Show GpuMat whit imshow with opengl flag

I am showing a cv::cuda::GpuMat whit cv::imshow:
cv::cuda::GpuMat myGpuMat;
cv::Ptrcv::cudacodec::VideoReader d_reader = cv::cudacodec::createVideoReader(fname);
cv::namedWindow(“GPU”, cv::WINDOW_OPENGL);
cv::imshow(“GPU”, cv::ogl::Texture2D(myGpuMat));

and its ok, but when i try to receive myGpuMat in a thread and buffer it, and second thread want to show it i have this error in setGlDevice() :
_err = “cannot set while device is active in this process”
it happens in opengl.cpp.

More details said here:

I wouldn’t use that approach I would download back to the host instead.

cv::imshow used to support GpuMat but it was removed when it was updated. I thought cv::ogl::Texture2D was a good replacement when I amended the sample you are using but I have since realized it has many limitations including leaking memory.

Then how can i show a GpuMat whitout download it? Its not efficient download it and pass it to opengl to draw it, i wanna pass it in the gpu memory. Is there a better way?

In the link I posted it was suggested it should work with QT but I haven’t tested this.