The model3 has this weird issue where the 2d and 3d planes are misaligned by 2 pixels. Originally I made a quick hack that shifted subviewports 2 pixels. But apparently that wasn't enough, as the issue effects everything. Thanks to HarryTuttle for pointing this out, and making a patch :)

This commit is contained in:
Ian Curtis 2017-03-19 01:33:45 +00:00
parent b19ceb0b6a
commit 9780f333b4
5 changed files with 13 additions and 22 deletions

View file

@ -703,14 +703,6 @@ void CNew3D::RenderViewport(UINT32 addr)
uint32_t matrixBase = vpnode[0x16] & 0xFFFFFF; // matrix base address uint32_t matrixBase = vpnode[0x16] & 0xFFFFFF; // matrix base address
if (vp->vpX) {
vp->vpX += 2;
}
if (vp->vpY) {
vp->vpY += 2;
}
LODBlendTable* tableTest = (LODBlendTable*)TranslateCullingAddress(vpnode[0x17]); LODBlendTable* tableTest = (LODBlendTable*)TranslateCullingAddress(vpnode[0x17]);
vp->angle_left = -atan2(*(float *)&vpnode[12], *(float *)&vpnode[13]); vp->angle_left = -atan2(*(float *)&vpnode[12], *(float *)&vpnode[13]);

View file

@ -536,24 +536,15 @@ void CRender2D::Setup2D(bool isBottom, bool clearAll)
glUseProgram(m_shaderProgram); glUseProgram(m_shaderProgram);
// Clear everything if requested or just overscan areas for wide screen mode // Clear everything if requested or just overscan areas for wide screen mode
if (clearAll) if (clearAll || isBottom)
{ {
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, m_totalXPixels, m_totalYPixels); glViewport(0, 0, m_totalXPixels, m_totalYPixels);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
else if (isBottom && g_Config.wideScreen)
{
// For now, clear w/ black (may want to use color 0 later)
glClearColor(0.0, 0.0, 0.0, 0.0);
glViewport(0, 0, m_xOffset, m_totalYPixels);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(m_xOffset + m_xPixels, 0, m_totalXPixels, m_totalYPixels);
glClear(GL_COLOR_BUFFER_BIT);
}
// Set up the viewport and orthogonal projection // Set up the viewport and orthogonal projection
glViewport(m_xOffset, m_yOffset, m_xPixels, m_yPixels); glViewport(m_xOffset - m_correction, m_yOffset + m_correction, m_xPixels, m_yPixels);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(0.0, 1.0, 1.0, 0.0, 1.0, -1.0); glOrtho(0.0, 1.0, 1.0, 0.0, 1.0, -1.0);
@ -672,6 +663,7 @@ bool CRender2D::Init(unsigned xOffset, unsigned yOffset, unsigned xRes, unsigned
m_yOffset = yOffset; m_yOffset = yOffset;
m_totalXPixels = totalXRes; m_totalXPixels = totalXRes;
m_totalYPixels = totalYRes; m_totalYPixels = totalYRes;
m_correction = (UINT32)(((yRes / 384.f) * 2) + 0.5f); // for some reason the 2d layer is 2 pixels off the 3D
// Create textures // Create textures
glActiveTexture(GL_TEXTURE0); // texture unit 0 glActiveTexture(GL_TEXTURE0); // texture unit 0

View file

@ -186,6 +186,7 @@ private:
unsigned m_yOffset = 0; unsigned m_yOffset = 0;
unsigned m_totalXPixels; // total display surface resolution unsigned m_totalXPixels; // total display surface resolution
unsigned m_totalYPixels; unsigned m_totalYPixels;
unsigned m_correction = 0;
// Shader programs and input data locations // Shader programs and input data locations
GLuint m_shaderProgram; // shader program object GLuint m_shaderProgram; // shader program object

View file

@ -1076,7 +1076,7 @@ CReal3D::CReal3D(void)
CReal3D::~CReal3D(void) CReal3D::~CReal3D(void)
{ {
// Dump memory // Dump memory
#if 0 #if 1
FILE *fp; FILE *fp;
fp = fopen("8c000000", "wb"); fp = fopen("8c000000", "wb");
if (NULL != fp) if (NULL != fp)

View file

@ -136,15 +136,21 @@ static bool SetGLGeometry(unsigned *xOffsetPtr, unsigned *yOffsetPtr, unsigned *
*xResPtr = (unsigned) xRes; *xResPtr = (unsigned) xRes;
*yResPtr = (unsigned) yRes; *yResPtr = (unsigned) yRes;
UINT32 correction = (UINT32)(((yRes / 384.f) * 2) + 0.5f);
glEnable(GL_SCISSOR_TEST);
// Scissor box (to clip visible area) // Scissor box (to clip visible area)
if (!g_Config.wideScreen) if (!g_Config.wideScreen)
{ {
if (VideoInfo->current_w > int(*xResPtr) || VideoInfo->current_h > int(*yResPtr)) if (VideoInfo->current_w > int(*xResPtr) || VideoInfo->current_h > int(*yResPtr))
{ {
glEnable(GL_SCISSOR_TEST); glScissor(*xOffsetPtr + correction, *yOffsetPtr + correction, *xResPtr - (correction*2), *yResPtr - (correction*2));
glScissor(*xOffsetPtr, *yOffsetPtr, *xResPtr, *yResPtr);
} }
} }
else {
glScissor(0, correction, *totalXResPtr, *totalYResPtr - (correction * 2));
}
return OKAY; return OKAY;
} }