From 8893f974351d7e5c94f71ded51ab081a9bba4870 Mon Sep 17 00:00:00 2001 From: Marcel Szewczyk Date: Fri, 8 Feb 2019 21:24:09 +0100 Subject: [PATCH] Handle odd screen resolution (POCOPHONE fix) --- core/rend/gles/gldraw.cpp | 13 +++++++++++-- core/rend/gles/gles.cpp | 12 +++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/core/rend/gles/gldraw.cpp b/core/rend/gles/gldraw.cpp index 1251e2722..8305ead56 100644 --- a/core/rend/gles/gldraw.cpp +++ b/core/rend/gles/gldraw.cpp @@ -1175,8 +1175,17 @@ void fullscreenQuadPrepareFramebuffer(float xScale, float yScale) { // Reduce width to keep 4:3 aspect ratio (640x480) u32 reducedWidth = 4 * screen_height / 3; - u32 reducedWidthOffset = (screen_width - reducedWidth) / 2; - glScissor(reducedWidthOffset, 0, reducedWidth, screen_height); + + // handle odd/even screen width + if (screen_width % 2 == 0) { + u32 reducedWidthOffset = (screen_width - reducedWidth) / 2; + glScissor(reducedWidthOffset, 0, reducedWidth, screen_height); + } + else { + u32 reducedWidthOffset = (screen_width + 1 - reducedWidth) / 2; + glScissor(reducedWidthOffset, 0, reducedWidth - 1, screen_height); + } + if (settings.rend.WideScreen && (pvrrc.fb_X_CLIP.min==0) && ((pvrrc.fb_X_CLIP.max+1)/xScale==640) && (pvrrc.fb_Y_CLIP.min==0) && ((pvrrc.fb_Y_CLIP.max+1)/yScale==480 )) diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index fc0191b0a..550d53ead 100755 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -1902,6 +1902,10 @@ bool RenderFrame() */ float dc2s_scale_h = screen_height / 480.0; float ds2s_offs_x = (screen_width - dc2s_scale_h * 640.0) / 2; + // handle odd screen width + if (screen_width % 2) { + ds2s_offs_x = (screen_width + 1 - dc2s_scale_h * 640.0) / 2; + } if (!is_rtt) { ShaderUniforms.scale_coefs[0] = 2.0f / (screen_width / dc2s_scale_h * scale_x); @@ -2118,7 +2122,13 @@ bool RenderFrame() width *= dc2s_scale_h; height *= dc2s_scale_h; } - glScissor(min_x + 0.5f, min_y + 0.5f, width + 0.5f, height + 0.5f); + // handle odd/even screen width + if (screen_width % 2 == 0) { + glScissor(min_x + 0.5f, min_y + 0.5f, width + 0.5f, height + 0.5f); + } + else { + glScissor(min_x + 0.5f, min_y + 0.5f, width + 0.5f - 1, height + 0.5f); + } glEnable(GL_SCISSOR_TEST); } }