int SDL_VIDEO_SetVsync(int value) { SDL_VIDEO_vsync = value; VIDEOMODE_Update(); /* Return false if vsync is requested but not available. */ return !SDL_VIDEO_vsync || SDL_VIDEO_vsync_available; }
void VIDEOMODE_ForceStandardScreen(int value) { VIDEOMODE_MODE_t prev_mode = CurrentDisplayMode(); force_standard_screen = value; if (prev_mode != CurrentDisplayMode()) VIDEOMODE_Update(); }
void VIDEOMODE_ForceWindowed(int value) { int prev_windowed = VIDEOMODE_windowed || force_windowed; force_windowed = value; if (prev_windowed != VIDEOMODE_windowed || force_windowed) VIDEOMODE_Update(); }
void VIDEOMODE_UpdateXEP80(void) { display_modes[VIDEOMODE_MODE_XEP80].src_height = XEP80_scrn_height; if (XEP80_char_height == 12) /* PAL */ display_modes[VIDEOMODE_MODE_XEP80].asp_ratio = xep80_aspect_ratio_pal; else display_modes[VIDEOMODE_MODE_XEP80].asp_ratio = xep80_aspect_ratio_ntsc; if (resolutions != NULL /* Display already initialised */ && CurrentDisplayMode() == VIDEOMODE_MODE_XEP80) VIDEOMODE_Update(); }
/* Sets an integer parameter and updates the video mode if needed. */ static int SetIntAndUpdateVideo(int *ptr, int value) { int old_value = *ptr; if (old_value != value) { *ptr = value; if (!VIDEOMODE_Update()) { *ptr = old_value; return FALSE; } } return TRUE; }
int VIDEOMODE_InitialiseDisplay(void) { /* PLATFORM_Initialise must be called earlier! */ resolutions = PLATFORM_AvailableResolutions(&resolutions_size); if (resolutions == NULL) { Log_print("Fatal error: System reports no display resolutions available"); return FALSE; } qsort(resolutions, resolutions_size, sizeof(VIDEOMODE_resolution_t), &CompareResolutions); RemoveDuplicateResolutions(); if (resolutions_size == 0) { Log_print("Fatal error: System reports no resolution higher than minimal %ux%u available", display_modes[0].min_w, display_modes[0].min_h); return FALSE; } /* Find the resolution from config file/command line in RESOLUTIONS. */ for (current_resolution = 0; current_resolution < resolutions_size; current_resolution ++) { if (resolutions[current_resolution].width >= init_fs_resolution.width && resolutions[current_resolution].height >= init_fs_resolution.height) break; } if (current_resolution >= resolutions_size) { /* No resolution found, using the biggest one. */ current_resolution = resolutions_size - 1; Log_print("Requested resolution %ux%u is too big, using %ux%u instead.", init_fs_resolution.width, init_fs_resolution.height, resolutions[current_resolution].width, resolutions[current_resolution].height); } else if (resolutions[current_resolution].width != init_fs_resolution.width || resolutions[current_resolution].height != init_fs_resolution.height) Log_print("Requested resolution %ux%u is not available, using %ux%u instead.", init_fs_resolution.width, init_fs_resolution.height, resolutions[current_resolution].width, resolutions[current_resolution].height); /* Autodetect host display aspect ratio if requested. */ if (VIDEOMODE_host_aspect_ratio_w == 0.0 || VIDEOMODE_host_aspect_ratio_h == 0.0) AutodetectHostAspect(&VIDEOMODE_host_aspect_ratio_w, &VIDEOMODE_host_aspect_ratio_h); UpdateTvSystemSettings(); if (!VIDEOMODE_Update()) { Log_print("Fatal error: Cannot initialise video"); return FALSE; } #if SUPPORTS_PLATFORM_PALETTEUPDATE PLATFORM_PaletteUpdate(); #endif return TRUE; }
int VIDEOMODE_SetHostAspect(double w, double h) { double old_w = VIDEOMODE_host_aspect_ratio_w; double old_h = VIDEOMODE_host_aspect_ratio_h; if (w < 0.0 || h < 0.0) return FALSE; if (w == 0.0 || h == 0.0) AutodetectHostAspect(&w, &h); VIDEOMODE_host_aspect_ratio_w = w; VIDEOMODE_host_aspect_ratio_h = h; if (!VIDEOMODE_Update()) { VIDEOMODE_host_aspect_ratio_w = old_w; VIDEOMODE_host_aspect_ratio_h = old_h; return FALSE; } return TRUE; }
int VIDEOMODE_SetCustomStretch(double value) { double old_value = VIDEOMODE_custom_stretch; unsigned int old_stretch = VIDEOMODE_stretch; if (value < 1.0) return FALSE; if (value != VIDEOMODE_custom_stretch || VIDEOMODE_stretch != VIDEOMODE_STRETCH_CUSTOM) { VIDEOMODE_custom_stretch = value; VIDEOMODE_stretch = VIDEOMODE_STRETCH_CUSTOM; if (!VIDEOMODE_Update()) { VIDEOMODE_custom_stretch = old_value; VIDEOMODE_stretch = old_stretch; return FALSE; } } return TRUE; }
int VIDEOMODE_SetCustomVerticalArea(unsigned int value) { unsigned int old_value = VIDEOMODE_custom_vertical_area; unsigned int old_area = VIDEOMODE_vertical_area; if (value < VIDEOMODE_MIN_VERTICAL_AREA) return FALSE; if (value > VIDEOMODE_MAX_VERTICAL_AREA) value = VIDEOMODE_MAX_VERTICAL_AREA; if (value != VIDEOMODE_custom_vertical_area || VIDEOMODE_vertical_area != VIDEOMODE_VERTICAL_CUSTOM) { VIDEOMODE_custom_vertical_area = value; VIDEOMODE_vertical_area = VIDEOMODE_VERTICAL_CUSTOM; if (!VIDEOMODE_Update()) { VIDEOMODE_custom_vertical_area = old_value; VIDEOMODE_vertical_area = old_area; return FALSE; } } return TRUE; }
int VIDEOMODE_SetCustomHorizontalArea(unsigned int value) { unsigned int old_value = VIDEOMODE_custom_horizontal_area; unsigned int old_area = VIDEOMODE_horizontal_area; if (value < VIDEOMODE_MIN_HORIZONTAL_AREA) return FALSE; if (value > VIDEOMODE_MAX_HORIZONTAL_AREA) value = VIDEOMODE_MAX_HORIZONTAL_AREA; if (value != VIDEOMODE_custom_horizontal_area || VIDEOMODE_horizontal_area != VIDEOMODE_HORIZONTAL_CUSTOM) { VIDEOMODE_custom_horizontal_area = value; VIDEOMODE_horizontal_area = VIDEOMODE_HORIZONTAL_CUSTOM; if (!VIDEOMODE_Update()) { VIDEOMODE_custom_horizontal_area = old_value; VIDEOMODE_horizontal_area = old_area; return FALSE; } } return TRUE; }
int PLATFORM_Exit(int run_monitor) { SDL_INPUT_Exit(); /* If the SDL window was left not closed, it would be unusable and hanging for the time the monitor is active. Also, with SDL_VIDEODRIVER=directx all keyboard presses in console would be still fetched by the SDL window after leaving the monitor. To avoid the problems, close the video subsystem. */ SDL_VIDEO_Exit(); Log_flushlog(); if (run_monitor) { #ifdef SOUND Sound_Pause(); #endif if (MONITOR_Run()) { /* Reinitialise the SDL subsystem. */ #ifdef MONITOR_BREAK if (!MONITOR_break_step) /*Do not initialise videomode when stepping through code */ #endif { SDL_VIDEO_InitSDL(); SDL_INPUT_Restart(); /* This call reopens the SDL window. */ VIDEOMODE_Update(); } #ifdef SOUND Sound_Continue(); #endif return 1; } } #ifdef SOUND Sound_Exit(); #endif return 0; }
int PLATFORM_Exit(int run_monitor) { int restart; SDL_INPUT_Exit(); /* If the SDL window was left not closed, it would be unusable and hanging for the time the monitor is active. Also, with SDL_VIDEODRIVER=directx all keyboard presses in console would be still fetched by the SDL window after leaving the monitor. To avoid the problems, close the video subsystem. */ SDL_VIDEO_Exit(); if (run_monitor) { #ifdef SOUND Sound_Pause(); #endif restart = MONITOR_Run(); #ifdef SOUND Sound_Continue(); #endif } else { restart = FALSE; } if (restart) { /* Reinitialise the SDL subsystem. */ SDL_VIDEO_InitSDL(); SDL_INPUT_Restart(); /* This call reopens the SDL window. */ VIDEOMODE_Update(); return 1; } SDL_Quit(); Log_flushlog(); return restart; }
void PLATFORM_SetVideoMode(VIDEOMODE_resolution_t const *res, int windowed, VIDEOMODE_MODE_t mode, int rotate90) { /* In SDL there's really no way to determine if a window is maximised. So we use a method that's not 100% sure: if we notice, that the windows's horizontal size equals desktop resolution, then we assume that the window is maximised. This works at least on Windows and Linux/KDE. */ window_maximised = windowed && res->width == desktop_resolution.width; #if HAVE_WINDOWS_H /* On Windows, choose Windib or DirectX backend when switching between fullscreen<->windowed. */ if (!user_video_driver && SDL_VIDEO_screen != NULL && ((SDL_VIDEO_screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) == windowed) { if (windowed) SDL_putenv("SDL_VIDEODRIVER=windib"); else SDL_putenv("SDL_VIDEODRIVER=directx"); /* SDL_VIDEODRIVER is only used when initialising the video subsystem. */ SDL_VIDEO_ReinitSDL(); } #if HAVE_OPENGL /* Reinitialise the video subsystem when switching between software<->OpenGL to avoid various SDL glitches and segfaults that might appear depending on the type of graphics hardware. */ else if (SDL_VIDEO_screen != NULL && SDL_VIDEO_opengl != currently_opengl) SDL_VIDEO_ReinitSDL(); #endif /* HAVE_OPENGL */ #endif /* HAVE_WINDOWS_H */ #if HAVE_OPENGL if (SDL_VIDEO_opengl) { if (!currently_opengl) SDL_VIDEO_screen = NULL; /* Switching to OpenGL can fail when the host machine doesn't support it. If so, revert to software mode. */ if (!SDL_VIDEO_GL_SetVideoMode(res, windowed, mode, rotate90)) { SDL_VIDEO_GL_Cleanup(); SDL_VIDEO_screen = NULL; SDL_VIDEO_opengl = SDL_VIDEO_opengl_available = FALSE; VIDEOMODE_Update(); } } else { if (currently_opengl) { SDL_VIDEO_GL_Cleanup(); SDL_VIDEO_screen = NULL; } SDL_VIDEO_SW_SetVideoMode(res, windowed, mode, rotate90); } currently_opengl = SDL_VIDEO_opengl; #else SDL_VIDEO_SW_SetVideoMode(res, windowed, mode, rotate90); #endif SDL_VIDEO_current_display_mode = mode; UpdateNtscFilter(mode); PLATFORM_DisplayScreen(); /* For unknown reason (maybe window manager-related), when SDL_SetVideoMode is called twice without calling SDL_PollEvent in between, SDL may throw an SDL_VIDEORESIZE event. (Happens on KDE4 in windowed mode during initialisation of the XEP80 handler (TV system = PAL), when it switches between 60Hz and 50Hz modes rapidly). If this event was processed, it would cause another screen resize, resulting in invalid window size. To avoid the glitch, we ignore all pending SDL_VIDEORESIZE events after each screen resize. */ for (;;) { SDL_Event event; int found = FALSE; SDL_PumpEvents(); while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_VIDEORESIZE)) > 0) found = TRUE; if (!found) break; } }
void VIDEOMODE_SetVideoSystem(int mode) { UpdateTvSystemSettings(); VIDEOMODE_Update(); }