Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit c22915a

Browse files
authored
Merge pull request #1767 from reicast/skmp/fix-portrait-scaling
rend: Fix portrait scaling, enable portrait mode in AndroidManifest.xml
2 parents f1d497a + 8972a1c commit c22915a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

libswirl/rend/gl4/gl4rend.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,11 +694,16 @@ static bool RenderFrame(u8* vram, bool isRenderFramebuffer)
694694
}
695695
else
696696
{
697-
dc2s_scale_h = screen_height / 480.0;
698-
ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2;
699-
//-1 -> too much to left
697+
dc2s_scale_h = screen_height / dc_height;
698+
ds2s_offs_x = (screen_width - dc2s_scale_h * dc_width * screen_stretching) / 2;
699+
700+
if (ds2s_offs_x < 0) {
701+
dc2s_scale_h = screen_width / dc_width;
702+
ds2s_offs_x = 0;
703+
}
704+
700705
gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching;
701-
gl4ShaderUniforms.scale_coefs[1] = -2.0f / dc_height;
706+
gl4ShaderUniforms.scale_coefs[1] = -2.0f / (screen_height / dc2s_scale_h);
702707
gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width;
703708
gl4ShaderUniforms.scale_coefs[3] = -1;
704709
}

libswirl/rend/gles/glesrend.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,10 +1245,16 @@ bool RenderFrame(u8* vram, bool isRenderFramebuffer)
12451245
}
12461246
else
12471247
{
1248-
dc2s_scale_h = screen_height / 480.0f;
1249-
ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0f * screen_stretching) / 2;
1248+
dc2s_scale_h = screen_height / dc_height;
1249+
ds2s_offs_x = (screen_width - dc2s_scale_h * dc_width * screen_stretching) / 2;
1250+
1251+
if (ds2s_offs_x < 0) {
1252+
dc2s_scale_h = screen_width / dc_width;
1253+
ds2s_offs_x = 0;
1254+
}
1255+
12501256
ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching;
1251-
ShaderUniforms.scale_coefs[1] = -2.0f / dc_height;
1257+
ShaderUniforms.scale_coefs[1] = -2.0f / (screen_height / dc2s_scale_h);
12521258
ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width;
12531259
ShaderUniforms.scale_coefs[3] = -1;
12541260
}

reicast/android-studio/reicast/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
<activity
5353
android:name="com.reicast.emulator.NativeGLActivity"
5454
android:configChanges="orientation|navigation|screenSize|screenLayout|uiMode|keyboard|keyboardHidden"
55-
android:screenOrientation="sensorLandscape"
5655
android:exported="true"/>
5756
<activity-alias
5857
android:name="com.reicast.emulator.MainActivity"

0 commit comments

Comments
 (0)