summaryrefslogtreecommitdiff
path: root/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
diff options
context:
space:
mode:
authorGravatar adityaruplaha2018-04-21 13:22:34 +0530
committerGravatar adityaruplaha2018-04-21 13:24:33 +0530
commitf48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a (patch)
tree551cdec2d10712ab347dc204ceb0340f8fa29b9f /src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
parentMerge pull request #323 from Hexagon12/stub-hid (diff)
downloadyuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.gz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.tar.xz
yuzu-f48d5e4c4c03ffc8c374b2ec5a2d2455050bbf8a.zip
SDL2: Implement fullscreen. (Original PR: citra-emu/citra#3607)
Diffstat (limited to 'src/yuzu_cmd/emu_window/emu_window_sdl2.cpp')
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index 3d7cd06a4..36d40a9b5 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -56,7 +56,28 @@ void EmuWindow_SDL2::OnResize() {
56 UpdateCurrentFramebufferLayout(width, height); 56 UpdateCurrentFramebufferLayout(width, height);
57} 57}
58 58
59EmuWindow_SDL2::EmuWindow_SDL2() { 59void EmuWindow_SDL2::Fullscreen() {
60 if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN) == 0) {
61 return;
62 }
63
64 NGLOG_ERROR(Frontend, "Fullscreening failed: {}", SDL_GetError());
65
66 // Try a different fullscreening method
67 NGLOG_INFO(Frontend, "Attempting to use borderless fullscreen...");
68 if (SDL_SetWindowFullscreen(render_window, SDL_WINDOW_FULLSCREEN_DESKTOP) == 0) {
69 return;
70 }
71
72 NGLOG_ERROR(Frontend, "Borderless fullscreening failed: {}", SDL_GetError());
73
74 // Fallback algorithm: Maximise window.
75 // Works on all systems (unless something is seriously wrong), so no fallback for this one.
76 NGLOG_INFO(Frontend, "Falling back on a maximised window...");
77 SDL_MaximizeWindow(render_window);
78}
79
80EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
60 InputCommon::Init(); 81 InputCommon::Init();
61 82
62 SDL_SetMainReady(); 83 SDL_SetMainReady();
@@ -90,6 +111,10 @@ EmuWindow_SDL2::EmuWindow_SDL2() {
90 exit(1); 111 exit(1);
91 } 112 }
92 113
114 if (fullscreen) {
115 Fullscreen();
116 }
117
93 gl_context = SDL_GL_CreateContext(render_window); 118 gl_context = SDL_GL_CreateContext(render_window);
94 119
95 if (gl_context == nullptr) { 120 if (gl_context == nullptr) {