jetson Tx1 x-windown character blink

n jetson TX1 the tegra_multimedia_api / sample / 12_camera_v4l2_cuda program uses X-window to draw characters in the video display window. Draw the characters in the video display when the flashing phenomenon. When X-window draws a character, it causes the drawn character to blink.

int
NvEglRenderer::renderInternal()
{
EGLImageKHR hEglImage;
bool frame_is_late = false;

EGLSyncKHR egl_sync;
int iErr;
hEglImage = NvEGLImageFromFd(egl_display, render_fd);
if (!hEglImage)
{
    COMP_ERROR_MSG("Could not get EglImage from fd. Not rendering");
    return -1;
}

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, hEglImage);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

iErr = glGetError();
if (iErr != GL_NO_ERROR)
{
    COMP_ERROR_MSG("glDrawArrays arrays failed:" << iErr);
    return -1;
}
egl_sync = eglCreateSyncKHR(egl_display, EGL_SYNC_FENCE_KHR, NULL);
if (egl_sync == EGL_NO_SYNC_KHR)
{
    COMP_ERROR_MSG("eglCreateSyncKHR() failed");
    return -1;
}
if (last_render_time.tv_sec != 0)
{
    pthread_mutex_lock(&render_lock);
    last_render_time.tv_sec += render_time_sec;
    last_render_time.tv_nsec += render_time_nsec;
    last_render_time.tv_sec += last_render_time.tv_nsec / 1000000000UL;
    last_render_time.tv_nsec %= 1000000000UL;

    if (isProfilingEnabled())
    {
        struct timeval cur_time;
        gettimeofday(&cur_time, NULL);
        if ((cur_time.tv_sec * 1000000.0 + cur_time.tv_usec) >
                (last_render_time.tv_sec * 1000000.0 +
                 last_render_time.tv_nsec / 1000.0))
        {
            frame_is_late = true;
        }
    }

    pthread_cond_timedwait(&render_cond, &render_lock,
            &last_render_time);

    pthread_mutex_unlock(&render_lock);
}
else
{
    struct timeval now;

    gettimeofday(&now, NULL);
    last_render_time.tv_sec = now.tv_sec;
    last_render_time.tv_nsec = now.tv_usec * 1000L;
}
eglSwapBuffers(egl_display, egl_surface);
if (eglGetError() != EGL_SUCCESS)
{
    COMP_ERROR_MSG("Got Error in eglSwapBuffers " << eglGetError());
    return -1;
}
if (eglClientWaitSyncKHR (egl_display, egl_sync,
            EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, EGL_FOREVER_KHR) == EGL_FALSE)
{
    COMP_ERROR_MSG("eglClientWaitSyncKHR failed!");
}

if (eglDestroySyncKHR(egl_display, egl_sync) != EGL_TRUE)
{
    COMP_ERROR_MSG("eglDestroySyncKHR failed!");
}
NvDestroyEGLImage(egl_display, hEglImage);

if (strlen(overlay_str) != 0)
{
    XSetForeground(x_display, gc,
                    BlackPixel(x_display, DefaultScreen(x_display)));
    XSetFont(x_display, gc, fontinfo->fid);
    XDrawString(x_display, x_window, gc, overlay_str_x_offset,
                overlay_str_y_offset, overlay_str, strlen(overlay_str));
}

/*
XSetForeground(x_display, gc,
BlackPixel(x_display, DefaultScreen(x_display)));
XSetFont(x_display, gc, fontinfo->fid);
XDrawString(x_display, x_window, gc, 500,
500, “hello world!”, strlen(“hello world!”));
XDrawString(x_display, x_window, gc, 600,
500, “hello world!”, strlen(“hello world!”));
XDrawLine(x_display, x_window, gc, 600,
500, 800, 700);
*/
profiler.finishProcessing(0, frame_is_late);

return 0;

}

Hi frank133788,
Could you share a clean patch so that we can apply directly? Not sure but it looks like you modify NvEglRenderer.cpp, not 12_camera_v4l2_cuda

/home/nvidia/tegra_multimedia_api / sample / 12_camera_v4l2_cuda/common/classes/NvEglRenderer.cpp

Hi frank,
So you add four lines into NvEglRenderer::renderInternal() ?

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_id);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, hEglImage);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

Hi DaneLLL
This is what I added in the program. Use this program to draw characters on the X-window, flashing. And I did not add this program with the original program will appear flashing.

XSetForeground(x_display, gc,
BlackPixel(x_display, DefaultScreen(x_display)));
XSetFont(x_display, gc, fontinfo->fid);
XDrawString(x_display, x_window, gc, 500,
500, “hello world!”, strlen(“hello world!”));
XDrawString(x_display, x_window, gc, 600,
500, “hello world!”, strlen(“hello world!”));
XDrawLine(x_display, x_window, gc, 600,
500, 800, 700);

Hi frank,
The implementation is based on EGL, so we suggest you use EGL APIs.

The program is part of the X-window it? The opengl part is EGL this I know.
Do you suggest that we draw characters using the EGL API?

frank133788,

If you want to use text, how about trying nvosd? This can directly add text on your plane.
[url]Unable to display text using nvosd_put_text() - Jetson TX2 - NVIDIA Developer Forums

thank you for you help