video: api cleanup

This commit is contained in:
Andrei "Akari" Alexeyev 2017-09-19 17:11:42 +03:00
parent 99adcc9afe
commit 73db5677c2
No known key found for this signature in database
GPG key ID: 048C3D2A5648B785
3 changed files with 18 additions and 25 deletions

View file

@ -901,7 +901,7 @@ static void notify_bindings(EventType type, int state, MenuData *menu) {
case BT_IntValue:
if(bind->configentry == CONFIG_FULLSCREEN) {
bind->selected = video_isfullscreen();
bind->selected = video_is_fullscreen();
}
break;

View file

@ -72,7 +72,7 @@ void video_set_viewport(void) {
glViewport((video.current.width - w) / 2, (video.current.height - h) / 2, w, h);
}
void video_update_vsync(void) {
static void video_update_vsync(void) {
if(global.frameskip || config_get_int(CONFIG_VSYNC) == 1) {
SDL_GL_SetSwapInterval(0);
} else {
@ -220,7 +220,7 @@ static void video_update_mode_settings(void) {
video_update_quality();
video_dispatch_mode_changed_event();
if(video_isfullscreen() && !config_get_int(CONFIG_FULLSCREEN_DESKTOP)) {
if(video_is_fullscreen() && !config_get_int(CONFIG_FULLSCREEN_DESKTOP)) {
video_check_fullscreen_sanity();
}
}
@ -320,6 +320,16 @@ static bool video_set_display_mode(int w, int h) {
return true;
}
static void video_set_fullscreen(bool fullscreen) {
uint32_t flags = fullscreen ? get_fullscreen_flag() : 0;
if(!SDL_SetWindowFullscreen(video.window, flags)) {
events_pause_keyrepeat();
} else {
log_warn("Failed to switch to %s mode: %s", modeflagsstr(flags), SDL_GetError());
}
}
void video_set_mode(int w, int h, bool fs, bool resizable) {
video.intended.width = w;
video.intended.height = h;
@ -423,30 +433,16 @@ void video_take_screenshot(void) {
SDL_RWclose(out);
}
bool video_isresizable(void) {
bool video_is_resizable(void) {
return SDL_GetWindowFlags(video.window) & SDL_WINDOW_RESIZABLE;
}
bool video_isfullscreen(void) {
bool video_is_fullscreen(void) {
return WINFLAGS_IS_FULLSCREEN(SDL_GetWindowFlags(video.window));
}
bool video_can_change_resolution(void) {
return !video_isfullscreen() || !config_get_int(CONFIG_FULLSCREEN_DESKTOP);
}
void video_set_fullscreen(bool fullscreen) {
uint32_t flags = fullscreen ? get_fullscreen_flag() : 0;
if(!SDL_SetWindowFullscreen(video.window, flags)) {
events_pause_keyrepeat();
} else {
log_warn("Failed to switch to %s mode: %s", modeflagsstr(flags), SDL_GetError());
}
}
void video_toggle_fullscreen(void) {
video_set_fullscreen(!video_isfullscreen());
return !video_is_fullscreen() || !config_get_int(CONFIG_FULLSCREEN_DESKTOP);
}
void video_resize(int w, int h) {

View file

@ -41,13 +41,10 @@ void video_shutdown(void);
void video_set_mode(int w, int h, bool fs, bool resizable);
void video_get_viewport_size(int *width, int *height);
void video_set_viewport(void);
bool video_isfullscreen(void);
bool video_isresizable(void);
bool video_is_fullscreen(void);
bool video_is_resizable(void);
bool video_can_change_resolution(void);
void video_set_fullscreen(bool);
void video_toggle_fullscreen(void);
void video_resize(int w, int h);
void video_update_vsync(void);
void video_take_screenshot(void);
#endif