src/SDL12_compat.c
changeset 103 685c0014eda1
parent 102 d45dadba9ff2
child 104 f3976d9769ab
     1.1 --- a/src/SDL12_compat.c	Wed Mar 06 02:56:23 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Wed Mar 06 03:08:45 2019 -0500
     1.3 @@ -718,7 +718,8 @@
     1.4  static SDL_Renderer *VideoRenderer20 = NULL;
     1.5  static SDL_Texture *VideoTexture20 = NULL;
     1.6  static SDL12_Surface *VideoSurface12 = NULL;
     1.7 -static SDL_bool VideoSurfaceUpdated = SDL_FALSE;
     1.8 +static Uint32 VideoSurfacePresentTicks = 0;
     1.9 +static Uint32 VideoSurfaceLastPresentTicks = 0;
    1.10  static SDL_Surface *VideoConvertSurface20 = NULL;
    1.11  static SDL_GLContext *VideoGLContext20 = NULL;
    1.12  static char *WindowTitle = NULL;
    1.13 @@ -2855,7 +2856,8 @@
    1.14  
    1.15      FIXME("setup screen saver");
    1.16  
    1.17 -    VideoSurfaceUpdated = SDL_FALSE;
    1.18 +    VideoSurfacePresentTicks = 0;
    1.19 +    VideoSurfaceLastPresentTicks = 0;
    1.20  
    1.21      return VideoSurface12;
    1.22  }
    1.23 @@ -3118,7 +3120,8 @@
    1.24      SDL20_UnlockTexture(VideoTexture20);
    1.25      SDL20_RenderCopy(VideoRenderer20, VideoTexture20, NULL, NULL);
    1.26      SDL20_RenderPresent(VideoRenderer20);
    1.27 -    VideoSurfaceUpdated = SDL_FALSE;
    1.28 +    VideoSurfaceLastPresentTicks = SDL20_GetTicks();
    1.29 +    VideoSurfacePresentTicks = 0;
    1.30  }
    1.31  
    1.32  DECLSPEC void SDLCALL
    1.33 @@ -3148,7 +3151,7 @@
    1.34          if (whole_screen) {  
    1.35              PresentScreen();  // flip it now.
    1.36          } else {
    1.37 -            VideoSurfaceUpdated = SDL_TRUE;  // flip it later.
    1.38 +            VideoSurfacePresentTicks = VideoSurfaceLastPresentTicks + 15;  // flip it later.
    1.39          }
    1.40      }
    1.41  }
    1.42 @@ -3184,9 +3187,10 @@
    1.43  SDL_PumpEvents(void)
    1.44  {
    1.45      // If the app is doing dirty rectangles, we set a flag and present the
    1.46 -    //  screen surface when they pump for new events, which we consider a
    1.47 -    //  sign that they are done rendering for the current frame.
    1.48 -    if (VideoSurfaceUpdated) {
    1.49 +    //  screen surface when they pump for new events if we're close to 60Hz,
    1.50 +    //  which we consider a sign that they are done rendering for the current
    1.51 +    //  frame and it would make sense to send it to the screen.
    1.52 +    if (VideoSurfacePresentTicks && SDL_TICKS_PASSED(SDL20_GetTicks(), VideoSurfacePresentTicks)) {
    1.53          PresentScreen();
    1.54      }
    1.55      SDL20_PumpEvents();