rendering text over video

"EStefano" <[email protected]>
Newsgroups gmane.comp.lib.sdl
Message-ID <[email protected]>
Hello folks,

I've got a small SDL2-based program which renders YUV video at up to 30 frames per second, which is working smoothly. I am now trying to render some text info over the video, like frame number or video quality figures (PSNR or whatever). I've followed the Lazy Foo production tutorial on TTF (http://lazyfoo.net/SDL_tutorials/lesson07/) and I've managed to make it work, but the text is blinking and seem it can't keep up with the video. I'm not sure if I'm doing something wrong or is just a limitation.

The skeleton of the code is the following:


Code:


    // the renderer
    if (NULL == (renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC|SDL_RENDERER_ACCELERATED)))
        error(ESDL, "Failed to create renderer: %s\n", SDL_GetError());

    // the video
    if (NULL == (video = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STREAMING, p->width, p->height)))
        error(ESDL, "Failed to create texture: %s\n", SDL_GetError());

    // the text
    surface = TTF_RenderText_Solid(font, "blended", color);
    text = SDL_CreateTextureFromSurface(renderer, surface);


    for ( frame = 0; frame <= last_frame; frame++)
    {
        ...

        if (display_info)
        {
           // render text
           SDL_RenderCopy(renderer, text, NULL, &text_rect);
           SDL_RenderPresent(renderer);
       }

        ...

        // render video
        SDL_RenderCopy(renderer, video, NULL, &video_rect);
        SDL_RenderPresent(renderer);

       ...
     }




Any suggestions?

Thanks

_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.