Can not create a valid EGLImageKHR from a color render buffer on QT


I am trying to save screenshot of a qml quick controls application on nvidia jetson xavier platform(running QT on wayland) by using native opengl functions .What I am doing is that using a render buffer with eglCreateImageKHR function and then send the EGLImage to another device through Qt socket communication. I can successfully create EGLImage that means that there is no error from eglGetError function.I tried to check EGLImageKHR by saving it to a bin file(also as png) but when I try to check the saved bin and png I see only noise on the screenshot as in the attachment.

Following is the code sample to create the EGLImageKHR from render buffer and then saving a tga_file from EGLImageKHR.


glGetIntegerv( GL_TEXTURE_BINDING_2D, &textureExi );
glGetIntegerv( GL_FRAMEBUFFER_BINDING, &fbExi );
glGetIntegerv( GL_RENDERBUFFER_BINDING, &rbExi);

qDebug() << "Text" << textureExi << "Frame" << fbExi << "Render" << rbExi;

glGetIntegerv(GL_PACK_ALIGNMENT, &rowPack);

mWinWidth = mwindow->width();
mWinHeight = mwindow->height();

glPixelStorei(GL_PACK_ALIGNMENT, 1);

glGenRenderbuffers( 1, &renderBuffer );
glBindRenderbuffer( GL_RENDERBUFFER, renderBuffer );
glRenderbufferStorage( GL_RENDERBUFFER, GL_RGB, mWinWidth, mWinHeight );
glBindRenderbuffer(GL_RENDERBUFFER, rbExi); //mwindow->openglContext()->defaultFramebufferObject());

if (glGetError()==GL_NO_ERROR)
//qDebug() << “Render buff storage is OK” << glGetError();
qDebug() << "Render buff storage error is " << glGetError();

glGenFramebuffers( 1, &frameBuffer );
glBindFramebuffer( GL_FRAMEBUFFER, frameBuffer);
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer);


qDebug() << "Framebuffer error is " << glGetError();
//qDebug() << “Framebuffer is OK” << glGetError();

glBindFramebuffer( GL_FRAMEBUFFER, fbExi );

m_display = reinterpret_cast

m_context = QGuiApplication::platformNativeInterface()->nativeResourceForContext(“eglcontext”, mwindow->openglContext());

/EGLImageKHR image2 = CreateImageKHR(m_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT,
NULL , config_attribs);

mImage = CreateImageKHR(m_display,m_context, EGL_GL_RENDERBUFFER_KHR,
reinterpret_cast(renderBuffer), nullptr);

if (mImage == EGL_NO_IMAGE_KHR)
qDebug(“failed to make image from target buffer: %s”, get_egl_error());
return -1;

FILE   *out = fopen("tga_file", "w");
short  TGAhead[] = {0, 2, 0, 0, 0, 0, 640, 480, 24};
fwrite(&TGAhead, sizeof(TGAhead), 1, out);
fwrite(mImage,  mWinWidth * mWinHeight*3, 1, out);


Could you please give me some hint to find out what is the reason of the issuetga_file (900.0 KB) ?


Hello ,

Any feedback on the issue ?