src/video/raspberry/SDL_rpiopengles.c
changeset 11694 2ce56475ad57
parent 11444 38f181f81476
child 11811 5d94cb6b24d3
     1.1 --- a/src/video/raspberry/SDL_rpiopengles.c	Mon Nov 06 15:29:24 2017 -0500
     1.2 +++ b/src/video/raspberry/SDL_rpiopengles.c	Tue Nov 07 09:10:32 2017 -0800
     1.3 @@ -19,6 +19,8 @@
     1.4    3. This notice may not be removed or altered from any source distribution.
     1.5  */
     1.6  #include "../../SDL_internal.h"
     1.7 +#include "SDL_hints.h"
     1.8 +#include "SDL_log.h"
     1.9  
    1.10  #if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL
    1.11  
    1.12 @@ -40,8 +42,27 @@
    1.13      return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0);
    1.14  }
    1.15  
    1.16 +int
    1.17 +RPI_GLES_SwapWindow(_THIS, SDL_Window * window) {
    1.18 +    SDL_WindowData *wdata = ((SDL_WindowData *) window->driverdata);
    1.19 +
    1.20 +    if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) {
    1.21 +        SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed.");
    1.22 +        return 0;
    1.23 +    }
    1.24 +
    1.25 +    /* Wait immediately for vsync (as if we only had two buffers), for low input-lag scenarios.
    1.26 +     * Run your SDL2 program with "SDL_RPI_DOUBLE_BUFFER=1 <program_name>" to enable this. */
    1.27 +    if (wdata->double_buffer) {
    1.28 +        SDL_LockMutex(wdata->vsync_cond_mutex);
    1.29 +        SDL_CondWait(wdata->vsync_cond, wdata->vsync_cond_mutex);
    1.30 +        SDL_UnlockMutex(wdata->vsync_cond_mutex);
    1.31 +    }
    1.32 +
    1.33 +    return 0;
    1.34 +}
    1.35 +
    1.36  SDL_EGL_CreateContext_impl(RPI)
    1.37 -SDL_EGL_SwapWindow_impl(RPI)
    1.38  SDL_EGL_MakeCurrent_impl(RPI)
    1.39  
    1.40  #endif /* SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL */