Просмотр исходного кода

opengl: default to vsync=0 everywhere.

This reverts commit 3ee29f2e7a3af825daf39ec980d5f92896773b45, among other
changes. This means getting a scary warning on the javascript console in
Emscripten by default, but this is easily fixed by setting a GL swap
interval at startup or creating a 2D renderer with the appropriate property
(or call to SDL_SetRenderVSync()).

Fixes #14625.
Ryan C. Gordon 2 месяцев назад
Родитель
Сommit
b3cdeb942a
2 измененных файлов с 3 добавлено и 11 удалено
  1. 1 9
      src/render/SDL_render.c
  2. 2 2
      src/video/SDL_egl.c

+ 1 - 9
src/render/SDL_render.c

@@ -1238,16 +1238,8 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
         SDL_AddWindowEventWatch(SDL_WINDOW_EVENT_WATCH_NORMAL, SDL_RendererEventWatch, renderer);
     }
 
-#ifdef SDL_PLATFORM_EMSCRIPTEN  // don't change vsync on Emscripten unless explicitly requested; we already set this with a mainloop, and a 0 default causes problems here.
-    if (SDL_HasProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER)) {
-        const int vsync = (int)SDL_GetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 0);
-        SDL_SetRenderVSync(renderer, vsync);
-    }
-#else  // everything else defaults to no vsync if not requested.
-    const int vsync = (int)SDL_GetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 0);
+    int vsync = (int)SDL_GetNumberProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER, 0);
     SDL_SetRenderVSync(renderer, vsync);
-#endif
-
     SDL_CalculateSimulatedVSyncInterval(renderer, window);
 
     SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,

+ 2 - 2
src/video/SDL_egl.c

@@ -1107,8 +1107,8 @@ SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surfa
         return NULL;
     }
 
-    // The default swap interval is 1, according to the spec
-    _this->egl_data->egl_swapinterval = 1;
+    // The default swap interval is 1, according to the spec, but SDL3's policy is to default vsync to off by default.
+    _this->egl_data->egl_swapinterval = 0;
 
     if (!SDL_EGL_MakeCurrent(_this, egl_surface, (SDL_GLContext)egl_context)) {
         // Delete the context