Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1767 from reicast/skmp/fix-portrait-scaling
Browse files Browse the repository at this point in the history
rend: Fix portrait scaling, enable portrait mode in AndroidManifest.xml
  • Loading branch information
skmp committed Jan 26, 2020
2 parents f1d497a + 8972a1c commit c22915a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions libswirl/rend/gl4/gl4rend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,16 @@ static bool RenderFrame(u8* vram, bool isRenderFramebuffer)
}
else
{
dc2s_scale_h = screen_height / 480.0;
ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0 * screen_stretching) / 2;
//-1 -> too much to left
dc2s_scale_h = screen_height / dc_height;
ds2s_offs_x = (screen_width - dc2s_scale_h * dc_width * screen_stretching) / 2;

if (ds2s_offs_x < 0) {
dc2s_scale_h = screen_width / dc_width;
ds2s_offs_x = 0;
}

gl4ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching;
gl4ShaderUniforms.scale_coefs[1] = -2.0f / dc_height;
gl4ShaderUniforms.scale_coefs[1] = -2.0f / (screen_height / dc2s_scale_h);
gl4ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width;
gl4ShaderUniforms.scale_coefs[3] = -1;
}
Expand Down
12 changes: 9 additions & 3 deletions libswirl/rend/gles/glesrend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1245,10 +1245,16 @@ bool RenderFrame(u8* vram, bool isRenderFramebuffer)
}
else
{
dc2s_scale_h = screen_height / 480.0f;
ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0f * screen_stretching) / 2;
dc2s_scale_h = screen_height / dc_height;
ds2s_offs_x = (screen_width - dc2s_scale_h * dc_width * screen_stretching) / 2;

if (ds2s_offs_x < 0) {
dc2s_scale_h = screen_width / dc_width;
ds2s_offs_x = 0;
}

ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x) * screen_stretching;
ShaderUniforms.scale_coefs[1] = -2.0f / dc_height;
ShaderUniforms.scale_coefs[1] = -2.0f / (screen_height / dc2s_scale_h);
ShaderUniforms.scale_coefs[2] = 1 - 2 * ds2s_offs_x / screen_width;
ShaderUniforms.scale_coefs[3] = -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
<activity
android:name="com.reicast.emulator.NativeGLActivity"
android:configChanges="orientation|navigation|screenSize|screenLayout|uiMode|keyboard|keyboardHidden"
android:screenOrientation="sensorLandscape"
android:exported="true"/>
<activity-alias
android:name="com.reicast.emulator.MainActivity"
Expand Down

0 comments on commit c22915a

Please sign in to comment.