|
@@ -19,6 +19,37 @@
|
|
|
#include "input_common/sdl/sdl.h"
|
|
#include "input_common/sdl/sdl.h"
|
|
|
#include "yuzu_cmd/emu_window/emu_window_sdl2.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) {
|
|
void EmuWindow_SDL2::OnMouseMotion(s32 x, s32 y) {
|
|
|
TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
|
|
TouchMoved((unsigned)std::max(x, 0), (unsigned)std::max(y, 0));
|
|
|
InputCommon::GetMotionEmu()->Tilt(x, y);
|
|
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_GREEN_SIZE, 8);
|
|
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
|
|
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0);
|
|
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,
|
|
std::string window_title = fmt::format("yuzu {} | {}-{}", Common::g_build_fullname,
|
|
|
Common::g_scm_branch, Common::g_scm_desc);
|
|
Common::g_scm_branch, Common::g_scm_desc);
|
|
@@ -171,7 +203,6 @@ EmuWindow_SDL2::EmuWindow_SDL2(bool fullscreen) {
|
|
|
if (fullscreen) {
|
|
if (fullscreen) {
|
|
|
Fullscreen();
|
|
Fullscreen();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
gl_context = SDL_GL_CreateContext(render_window);
|
|
gl_context = SDL_GL_CreateContext(render_window);
|
|
|
|
|
|
|
|
if (gl_context == nullptr) {
|
|
if (gl_context == nullptr) {
|
|
@@ -280,3 +311,7 @@ void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(
|
|
|
|
|
|
|
|
SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second);
|
|
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>();
|
|
|
|
|
+}
|