Added "Reverse Side by Side" Sterioscopic 3D mode

This commit is contained in:
OpenSauce04 2024-08-24 13:17:45 +01:00 committed by OpenSauce
parent 8af024bddb
commit a30f9a8281
7 changed files with 53 additions and 15 deletions

View File

@ -166,6 +166,7 @@
<string-array name="render3dModes"> <string-array name="render3dModes">
<item>@string/off</item> <item>@string/off</item>
<item>@string/side_by_side</item> <item>@string/side_by_side</item>
<item>@string/reverse_side_by_side</item>
<item>@string/anaglyph</item> <item>@string/anaglyph</item>
<item>@string/interlaced</item> <item>@string/interlaced</item>
<item>@string/reverse_interlaced</item> <item>@string/reverse_interlaced</item>

View File

@ -563,6 +563,7 @@
<!-- Render 3D modes --> <!-- Render 3D modes -->
<string name="side_by_side">Side by Side</string> <string name="side_by_side">Side by Side</string>
<string name="reverse_side_by_side">Reverse Side by Side</string>
<string name="anaglyph">Anaglyph</string> <string name="anaglyph">Anaglyph</string>
<string name="interlaced">Interlaced</string> <string name="interlaced">Interlaced</string>
<string name="reverse_interlaced">Reverse Interlaced</string> <string name="reverse_interlaced">Reverse Interlaced</string>

View File

@ -56,10 +56,11 @@ enum class PortraitLayoutOption : u32 {
enum class StereoRenderOption : u32 { enum class StereoRenderOption : u32 {
Off = 0, Off = 0,
SideBySide = 1, SideBySide = 1,
Anaglyph = 2, ReverseSideBySide = 2,
Interlaced = 3, Anaglyph = 3,
ReverseInterlaced = 4, Interlaced = 4,
CardboardVR = 5 ReverseInterlaced = 5,
CardboardVR = 6
}; };
// Which eye to render when 3d is off. 800px wide mode could be added here in the future, when // Which eye to render when 3d is off. 800px wide mode could be added here in the future, when

View File

@ -66,14 +66,17 @@ bool EmuWindow::IsWithinTouchscreen(const Layout::FramebufferLayout& layout, uns
} }
#endif #endif
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide) { Settings::StereoRenderOption render_3d_mode = Settings::values.render_3d.GetValue();
if (render_3d_mode == Settings::StereoRenderOption::SideBySide ||
render_3d_mode == Settings::StereoRenderOption::ReverseSideBySide) {
return (framebuffer_y >= layout.bottom_screen.top && return (framebuffer_y >= layout.bottom_screen.top &&
framebuffer_y < layout.bottom_screen.bottom && framebuffer_y < layout.bottom_screen.bottom &&
((framebuffer_x >= layout.bottom_screen.left / 2 && ((framebuffer_x >= layout.bottom_screen.left / 2 &&
framebuffer_x < layout.bottom_screen.right / 2) || framebuffer_x < layout.bottom_screen.right / 2) ||
(framebuffer_x >= (layout.bottom_screen.left / 2) + (layout.width / 2) && (framebuffer_x >= (layout.bottom_screen.left / 2) + (layout.width / 2) &&
framebuffer_x < (layout.bottom_screen.right / 2) + (layout.width / 2)))); framebuffer_x < (layout.bottom_screen.right / 2) + (layout.width / 2))));
} else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::CardboardVR) { } else if (render_3d_mode == Settings::StereoRenderOption::CardboardVR) {
return (framebuffer_y >= layout.bottom_screen.top && return (framebuffer_y >= layout.bottom_screen.top &&
framebuffer_y < layout.bottom_screen.bottom && framebuffer_y < layout.bottom_screen.bottom &&
((framebuffer_x >= layout.bottom_screen.left && ((framebuffer_x >= layout.bottom_screen.left &&
@ -90,14 +93,18 @@ bool EmuWindow::IsWithinTouchscreen(const Layout::FramebufferLayout& layout, uns
} }
std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) const { std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) const {
Settings::StereoRenderOption render_3d_mode = Settings::values.render_3d.GetValue();
if (new_x >= framebuffer_layout.width / 2) { if (new_x >= framebuffer_layout.width / 2) {
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide) if (render_3d_mode == Settings::StereoRenderOption::SideBySide ||
render_3d_mode == Settings::StereoRenderOption::ReverseSideBySide)
new_x -= framebuffer_layout.width / 2; new_x -= framebuffer_layout.width / 2;
else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::CardboardVR) else if (render_3d_mode == Settings::StereoRenderOption::CardboardVR)
new_x -= new_x -=
(framebuffer_layout.width / 2) - (framebuffer_layout.cardboard.user_x_shift * 2); (framebuffer_layout.width / 2) - (framebuffer_layout.cardboard.user_x_shift * 2);
} }
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide) { if (render_3d_mode == Settings::StereoRenderOption::SideBySide ||
render_3d_mode == Settings::StereoRenderOption::ReverseSideBySide) {
new_x = std::max(new_x, framebuffer_layout.bottom_screen.left / 2); new_x = std::max(new_x, framebuffer_layout.bottom_screen.left / 2);
new_x = std::min(new_x, framebuffer_layout.bottom_screen.right / 2 - 1); new_x = std::min(new_x, framebuffer_layout.bottom_screen.right / 2 - 1);
} else { } else {
@ -122,18 +129,22 @@ void EmuWindow::CreateTouchState() {
} }
bool EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { bool EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
Settings::StereoRenderOption render_3d_mode = Settings::values.render_3d.GetValue();
if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y))
return false; return false;
if (framebuffer_x >= framebuffer_layout.width / 2) { if (framebuffer_x >= framebuffer_layout.width / 2) {
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide) if (render_3d_mode == Settings::StereoRenderOption::SideBySide ||
render_3d_mode == Settings::StereoRenderOption::ReverseSideBySide)
framebuffer_x -= framebuffer_layout.width / 2; framebuffer_x -= framebuffer_layout.width / 2;
else if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::CardboardVR) else if (render_3d_mode == Settings::StereoRenderOption::CardboardVR)
framebuffer_x -= framebuffer_x -=
(framebuffer_layout.width / 2) - (framebuffer_layout.cardboard.user_x_shift * 2); (framebuffer_layout.width / 2) - (framebuffer_layout.cardboard.user_x_shift * 2);
} }
std::scoped_lock guard(touch_state->mutex); std::scoped_lock guard(touch_state->mutex);
if (Settings::values.render_3d.GetValue() == Settings::StereoRenderOption::SideBySide) { if (render_3d_mode == Settings::StereoRenderOption::SideBySide ||
render_3d_mode == Settings::StereoRenderOption::ReverseSideBySide) {
touch_state->touch_x = touch_state->touch_x =
static_cast<float>(framebuffer_x - framebuffer_layout.bottom_screen.left / 2) / static_cast<float>(framebuffer_x - framebuffer_layout.bottom_screen.left / 2) /
(framebuffer_layout.bottom_screen.right / 2 - (framebuffer_layout.bottom_screen.right / 2 -

View File

@ -234,6 +234,11 @@
<string>Side by Side</string> <string>Side by Side</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Reverse Side by Side</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Anaglyph</string> <string>Anaglyph</string>

View File

@ -750,6 +750,15 @@ void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,
top_screen_top, top_screen_width / 2, top_screen_height, orientation); top_screen_top, top_screen_width / 2, top_screen_height, orientation);
break; break;
} }
case Settings::StereoRenderOption::ReverseSideBySide: {
DrawSingleScreen(screen_infos[1], top_screen_left / 2, top_screen_top, top_screen_width / 2,
top_screen_height, orientation);
glUniform1i(uniform_layer, 1);
DrawSingleScreen(screen_infos[0],
static_cast<float>((top_screen_left / 2) + (layout.width / 2)),
top_screen_top, top_screen_width / 2, top_screen_height, orientation);
break;
}
case Settings::StereoRenderOption::CardboardVR: { case Settings::StereoRenderOption::CardboardVR: {
DrawSingleScreen(screen_infos[0], top_screen_left, top_screen_top, top_screen_width, DrawSingleScreen(screen_infos[0], top_screen_left, top_screen_top, top_screen_width,
top_screen_height, orientation); top_screen_height, orientation);
@ -790,7 +799,8 @@ void RendererOpenGL::DrawBottomScreen(const Layout::FramebufferLayout& layout,
bottom_screen_width, bottom_screen_height, orientation); bottom_screen_width, bottom_screen_height, orientation);
break; break;
} }
case Settings::StereoRenderOption::SideBySide: { case Settings::StereoRenderOption::SideBySide: // Bottom screen is identical on both sides
case Settings::StereoRenderOption::ReverseSideBySide: {
DrawSingleScreen(screen_infos[2], bottom_screen_left / 2, bottom_screen_top, DrawSingleScreen(screen_infos[2], bottom_screen_left / 2, bottom_screen_top,
bottom_screen_width / 2, bottom_screen_height, orientation); bottom_screen_width / 2, bottom_screen_height, orientation);
glUniform1i(uniform_layer, 1); glUniform1i(uniform_layer, 1);

View File

@ -1,4 +1,4 @@
// Copyright 2023 Citra Emulator Project // Copyright Citra Emulator Project / Lime3DS Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -694,6 +694,14 @@ void RendererVulkan::DrawTopScreen(const Layout::FramebufferLayout& layout,
top_screen_top, top_screen_width / 2, top_screen_height, orientation); top_screen_top, top_screen_width / 2, top_screen_height, orientation);
break; break;
} }
case Settings::StereoRenderOption::ReverseSideBySide: {
DrawSingleScreen(1, top_screen_left / 2, top_screen_top, top_screen_width / 2,
top_screen_height, orientation);
draw_info.layer = 1;
DrawSingleScreen(0, static_cast<float>((top_screen_left / 2) + (layout.width / 2)),
top_screen_top, top_screen_width / 2, top_screen_height, orientation);
break;
}
case Settings::StereoRenderOption::CardboardVR: { case Settings::StereoRenderOption::CardboardVR: {
DrawSingleScreen(0, top_screen_left, top_screen_top, top_screen_width, top_screen_height, DrawSingleScreen(0, top_screen_left, top_screen_top, top_screen_width, top_screen_height,
orientation); orientation);
@ -733,7 +741,8 @@ void RendererVulkan::DrawBottomScreen(const Layout::FramebufferLayout& layout,
bottom_screen_height, orientation); bottom_screen_height, orientation);
break; break;
} }
case Settings::StereoRenderOption::SideBySide: { case Settings::StereoRenderOption::SideBySide: // Bottom screen is identical on both sides
case Settings::StereoRenderOption::ReverseSideBySide: {
DrawSingleScreen(2, bottom_screen_left / 2, bottom_screen_top, bottom_screen_width / 2, DrawSingleScreen(2, bottom_screen_left / 2, bottom_screen_top, bottom_screen_width / 2,
bottom_screen_height, orientation); bottom_screen_height, orientation);
draw_info.layer = 1; draw_info.layer = 1;