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.
This commit is contained in:
刘皓 2025-06-23 18:34:35 -04:00
parent 08ad3e9f8f
commit c97b4b8b6e
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 11 additions and 1 deletions

View file

@ -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)) {

View file

@ -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);
}