nvJPEG Encode directly from an OpenGL Texture?

I’m new to CUDA in general, but I was recently experimenting with the nvJPEG Encode library. My use case involves a texture that’s already on the graphics card, and while I could download the texture with glGetTexImage, this is a slow operation and it would stand to reason that there’s some way of using the OpenGL interop to access the GPU memory directly.

Or, would I be better served to allocate memory with cudaMalloc and somehow use cudaMemcpy to make a copy of the texture on the graphics card first? Can nvjpegEncodeImage take a pointer to memory on the GPU or does it only take a pointer to CPU memory? Am I on the right track at all?

Thanks!
Michael