diff options
author | bunnei <bunneidev@gmail.com> | 2019-04-14 04:08:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-14 04:08:40 +0200 |
commit | 065f83c6c321c9672cda9b89c09bef6c7f3c5472 (patch) | |
tree | 3efd50ea836f1ab052581108f1fa218a22e73b62 /src/yuzu_cmd | |
parent | Merge pull request #2389 from FreddyFunk/rename-gamedir (diff) | |
parent | bootmanager: Bypass input focus issues (diff) | |
download | yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.tar yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.tar.gz yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.tar.bz2 yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.tar.lz yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.tar.xz yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.tar.zst yuzu-065f83c6c321c9672cda9b89c09bef6c7f3c5472.zip |
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 37 | ||||
-rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.h | 2 |
2 files changed, 38 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 de7a26e14..68a176032 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp @@ -19,6 +19,37 @@ #include "input_common/sdl/sdl.h" #include "yuzu_cmd/emu_window/emu_window_sdl2.h" +class SDLGLContext : public Core::Frontend::GraphicsContext { +public: + explicit SDLGLContext() { + // create a hidden window to make the shared context against + window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, // x position + SDL_WINDOWPOS_UNDEFINED, // y position + Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height, + SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN); + context = SDL_GL_CreateContext(window); + } + + ~SDLGLContext() { + SDL_GL_DeleteContext(context); + SDL_DestroyWindow(window); + } + + void MakeCurrent() override { + SDL_GL_MakeCurrent(window, context); + } + + void DoneCurrent() override { + SDL_GL_MakeCurrent(window, nullptr); + } + + void SwapBuffers() override {} + +private: + SDL_Window* window; + SDL_GLContext context; +}; + void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) { TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0)); InputCommon::GetMotionEmu()->Tilt(x, y); @@ -153,6 +184,7 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) { SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname, Common::g_scm_branch, Common::g_scm_desc); @@ -171,7 +203,6 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) { if (fullscreen) { Fullscreen(); } - gl_context = SDL_GL_CreateContext(render_window); if (gl_context == nullptr) { @@ -278,3 +309,7 @@ void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest( SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); } + +std::unique_ptr<Core::Frontend::GraphicsContext> EmuWindow_SDL2::CreateSharedContext() const { + return std::make_unique<SDLGLContext>(); +} diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index b0d4116cc..17e98227f 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h @@ -27,6 +27,8 @@ public: /// Releases the GL context from the caller thread void DoneCurrent() override; + std::unique_ptr<Core::Frontend::GraphicsContext> CreateSharedContext() const override; + /// Whether the window is still open, and a close request hasn't yet been sent bool IsOpen() const; |