static int vout_mode_overlay = -1, vout_mode_overlay2x = -1, vout_mode_gl = -1;
static void *display, *window;
static int gl_quirks;
static int vout_mode_overlay = -1, vout_mode_overlay2x = -1, vout_mode_gl = -1;
static void *display, *window;
static int gl_quirks;
+ // skip GL recreation if window doesn't change - avoids flicker
+ if (plat_target.vout_method == vout_mode_gl && plat_sdl_gl_active
+ && plat_target.vout_fullscreen == old_fullscreen
+ && w == prev_w && h == prev_h && !force)
+ {
+ return 0;
+ }
+
- plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 0, flags);
+ if (!plat_sdl_screen || screen_flags != flags ||
+ plat_sdl_screen->w != win_w || plat_sdl_screen->h != win_h)
+ plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 0, flags);
+ screen_flags = flags;
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
plat_target.vout_method = 0;
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
plat_target.vout_method = 0;
if (plat_target.vout_method == vout_mode_overlay
|| plat_target.vout_method == vout_mode_overlay2x) {
if (plat_target.vout_method == vout_mode_overlay
|| plat_target.vout_method == vout_mode_overlay2x) {
plat_sdl_overlay = SDL_CreateYUVOverlay(W, h, SDL_UYVY_OVERLAY, plat_sdl_screen);
plat_sdl_overlay = SDL_CreateYUVOverlay(W, h, SDL_UYVY_OVERLAY, plat_sdl_screen);
if ((long)plat_sdl_overlay->pixels[0] & 3)
fprintf(stderr, "warning: overlay pointer is unaligned\n");
plat_sdl_overlay_clear();
if ((long)plat_sdl_overlay->pixels[0] & 3)
fprintf(stderr, "warning: overlay pointer is unaligned\n");
plat_sdl_overlay_clear();
- plat_sdl_gl_active = (gl_init(display, window, &gl_quirks) == 0);
+ int sw = plat_sdl_screen->w, sh = plat_sdl_screen->h;
+ plat_sdl_gl_active = (gl_init(display, window, &gl_quirks, sw, sh) == 0);
if (!plat_sdl_gl_active) {
fprintf(stderr, "warning: could not init GL.\n");
plat_target.vout_method = 0;
if (!plat_sdl_gl_active) {
fprintf(stderr, "warning: could not init GL.\n");
plat_target.vout_method = 0;
- plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 16, flags);
+ if (!plat_sdl_screen || screen_flags != flags ||
+ plat_sdl_screen->w != win_w || plat_sdl_screen->h != win_h)
+ plat_sdl_screen = SDL_SetVideoMode(win_w, win_h, 16, flags);
+ screen_flags = flags;
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
return -1;
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
return -1;
- plat_sdl_gl_active = (gl_init(display, window, &gl_quirks) == 0);
+ plat_sdl_gl_active = (gl_init(display, window, &gl_quirks, sw, sh) == 0);
- ret = plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 1);
- if (ret != 0) {
+ plat_sdl_screen = SDL_SetVideoMode(g_menuscreen_w, g_menuscreen_h, 16, SDL_HWSURFACE);
+ if (plat_sdl_screen == NULL) {
plat_sdl_screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE);
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
plat_sdl_screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE);
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
- ret = gl_init(display, window, &gl_quirks);
+ ret = gl_init(display, window, &gl_quirks, g_menuscreen_w, g_menuscreen_h);