使用 SDL2 绘制多个 SDL_Texture 时闪烁

Flickering while drawing multiple SDL_Texture using SDL2

我已经设置了一个 SDL2 渲染器,并且我有两个纹理要绘制到屏幕上。当我单独执行此操作时,它工作正常。但是当我把它们画在一起时,纹理在闪烁。后台缓冲区有问题吗?我还需要做些什么来启用双缓冲区吗?

这是我正在做的事情:

    Renderer::m_Renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    if (Renderer::m_Renderer == nullptr){
        SDL_DestroyWindow(win);
        std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
        SDL_Quit();
    }

    while (!m_bQuit) {
        m_tCurrentFrameTime = clock();

        // Input
        while (SDL_PollEvent(&m_Event)) {
            switch (m_Event.type) {
                case SDL_QUIT:
                    m_bQuit = true;
                    break;

                default:
                    break;
            }
        }

       // Update

    SDL_RenderCopyEx(m_Renderer, m_tBackgroundTexture, NULL, &m_rRect, m_fRotation, NULL, SDL_FLIP_NONE);
    SDL_RenderPresent(Renderer::getRenderer());

    SDL_RenderCopyEx(m_Renderer, m_tCharacterTexture, NULL, &m_rRect, m_fRotation, NULL, SDL_FLIP_NONE);
    SDL_RenderPresent(m_Renderer);


        // Clear screen
        SDL_RenderClear(m_Renderer);
    }

渲染两个纹理 然后 SDL_RenderPresent(),而不是 SDL_RenderPresent() 每个

所以:

SDL_RenderCopyEx(m_Renderer, m_tBackgroundTexture, NULL, &m_rRect, m_fRotation, NULL, SDL_FLIP_NONE);
SDL_RenderCopyEx(m_Renderer, m_tCharacterTexture, NULL, &m_rRect, m_fRotation, NULL, SDL_FLIP_NONE);
SDL_RenderPresent(m_Renderer);

// Clear screen
SDL_RenderClear(m_Renderer);