JTMC - EGLStream - CUDA/OpenGL interop


this topic is related to JTMC Project

I want capture video from ZWO camera, pass it to CUDA for processing (debayer, color space conversion) and finally pass it to GL texture where i want to display it on quad. I chosen EGL as I want to minimize memcpys and also, later I want to pass data to video encoder instead of GL.

Unfortunately, I can’t get EGL Stream work :-(. I would like to get it working on both, Nano and Xavier NG devkits. Currently I am developing it on NG

I followed docs and I did:

  • Open X display
  • Create X Window
  • Create GL context
  • Gen GL texture
  • Bind texture to texturing unit with GL_TEXTURE_EXTERNAL_OES
  • Get EGL extension proc addresses
  • Create EGL display from X display
  • Initialize EGL
  • Create EGL Stream
  • Connect consumer to the stream using eglStreamConsumerGLTextureExtrenalKHR

When I call

if (!eglStreamConsumerGLTextureExternalKHR(eglDisplay, eglStream)) {

this fails with 0x3002. I tried to find how to get it work from examples but… CUDA/Graphics examples and Kronos docs are for rocket engineers. I can’t find out how to make this work…

This is what I have so far:

main.c (13.5 KB)

I compile it with:

/usr/local/cuda/bin/nvcc -g main.c -o main -lX11 -lGL -lGLU -lEGL -lcuda -lGLESv2 -L/usr/lib/aarch64-linux-gnu/

Please refer to this implementation:


It is used in several samples, such as 00_video_decode. You may refer to the default sample to find deviation.


thanks for reference. It seems to me that this example is using EGLImage instead of EGLStream. Isn’t is possible to use the stream?

The samples may help:


Please take a look and give it a try.