From c97b4b8b6ef4cfe845905f9abd0cd849a58e63d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=9A=93?= Date: Mon, 23 Jun 2025 18:34:35 -0400 Subject: [PATCH] Don't vertically flip the screen in libretro builds Libretro provides the option to make the libretro frontend vertically flip the video output when using OpenGL, so let's just allow the frontend to do that instead of doing it manually. It might be more efficient. --- src/core.cpp | 2 +- src/display/graphics.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core.cpp b/src/core.cpp index 1cf595ed..ad43eb86 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -2205,7 +2205,7 @@ extern "C" RETRO_API bool retro_load_game(const struct retro_game_info *info) { }; hw_render.context_destroy = nullptr; hw_render.cache_context = true; - hw_render.bottom_left_origin = true; + hw_render.bottom_left_origin = false; if (hw_render.context_type = RETRO_HW_CONTEXT_OPENGL_CORE, hw_render.version_major = 4, hw_render.version_minor = 6, environment(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render)) { log_printf(RETRO_LOG_INFO, "Using OpenGL 4.6 graphics driver\n"); } else if (hw_render.context_type = RETRO_HW_CONTEXT_OPENGL_CORE, hw_render.version_major = 4, hw_render.version_minor = 5, environment(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render)) { diff --git a/src/display/graphics.cpp b/src/display/graphics.cpp index 9edd600b..d74c8ce7 100644 --- a/src/display/graphics.cpp +++ b/src/display/graphics.cpp @@ -1272,16 +1272,26 @@ struct GraphicsPrivate { metaBlitBufferFlippedScaled(scRes, scaleIsSpecial); GLMeta::blitRectangle( IntRect(0, 0, scRes.x, scRes.y), +#ifdef MKXPZ_RETRO + // Don't need to vertically flip the screen in libretro builds because the libretro frontend will do it for us + IntRect(scOffset.x, scOffset.y, scSize.x, scSize.y), +#else IntRect(scOffset.x, (scSize.y + scOffset.y), scSize.x, -scSize.y), +#endif // MKXPZ_RETRO GLMeta::smoothScalingMethod(scaleIsSpecial) == Bilinear); } void metaBlitBufferFlippedScaled(const Vec2i &sourceSize, int scaleIsSpecial, bool forceNearestNeighbor=false) { GLMeta::blitRectangle(IntRect(0, 0, sourceSize.x, sourceSize.y), +#ifdef MKXPZ_RETRO + // Don't need to vertically flip the screen in libretro builds because the libretro frontend will do it for us + IntRect(scOffset.x, scOffset.y, scSize.x, scSize.y), +#else IntRect(scOffset.x, scSize.y+scOffset.y, scSize.x, -scSize.y), +#endif // MKXPZ_RETRO !forceNearestNeighbor && GLMeta::smoothScalingMethod(scaleIsSpecial) == Bilinear); }