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

Hello,

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 .

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();
}
else
{
qDebug() << "Render buff storage error is " << glGetError();
}

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

printFramebufferInfo(frameBuffer);

if( glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
qDebug() << "Framebuffer error is " << glGetError();
}
else
{
//qDebug() << “Framebuffer is OK” << glGetError();
}

glBindFramebuffer( GL_FRAMEBUFFER, fbExi );

m_display = reinterpret_cast
(reinterpret_cast<void*>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration(“egldisplay”)));

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

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

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);
fflush(out);
fclose(out);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Could you please give me some hint to find out what is the reason of the issue ?
Regards

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.