1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Fix mirror viewport.

This commit is contained in:
Sergey Lipskiy 2014-12-23 10:49:59 +06:00
parent 69cf6a1901
commit e139173e77
2 changed files with 16 additions and 10 deletions

View File

@ -532,9 +532,9 @@ void OGLRender::_updateCullFace() const
glEnable( GL_CULL_FACE );
if (gSP.geometryMode & G_CULL_BACK)
glCullFace( GL_BACK );
glCullFace(GL_BACK);
else
glCullFace( GL_FRONT );
glCullFace(GL_FRONT);
}
else
glDisable( GL_CULL_FACE );
@ -544,12 +544,14 @@ void OGLRender::_updateViewport() const
{
OGLVideo & ogl = video();
if (!frameBufferList().isFboMode()) {
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1]*2.0f) * ogl.getScaleY()) : (GLint)((VI.height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
glViewport( (GLint)(gSP.viewport.x * ogl.getScaleX()), Y + ogl.getHeightOffset(),
const GLint X = gSP.viewport.vscale[0] < 0 ? (GLint)((gSP.viewport.x + gSP.viewport.vscale[0] * 2.0f) * ogl.getScaleX()) : (GLint)(gSP.viewport.x * ogl.getScaleX());
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * ogl.getScaleY()) : (GLint)((VI.height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
glViewport( X, Y + ogl.getHeightOffset(),
max((GLint)(gSP.viewport.width * ogl.getScaleX()), 0), max((GLint)(gSP.viewport.height * ogl.getScaleY()), 0) );
} else {
const GLint X = gSP.viewport.vscale[0] < 0 ? (GLint)((gSP.viewport.x + gSP.viewport.vscale[0] * 2.0f) * ogl.getScaleX()) : (GLint)(gSP.viewport.x * ogl.getScaleX());
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * ogl.getScaleY()) : (GLint)((frameBufferList().getCurrent()->m_height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
glViewport((GLint)(gSP.viewport.x * ogl.getScaleX()), Y,
glViewport(X, Y,
max((GLint)(gSP.viewport.width * ogl.getScaleX()), 0), max((GLint)(gSP.viewport.height * ogl.getScaleY()), 0) );
}
}

14
gSP.cpp
View File

@ -326,11 +326,12 @@ void gSPProcessVertex4(u32 v)
}
gSPTransformVertex4(v, gSP.matrix.combined );
if (gDP.otherMode.depthSource == G_ZS_PRIM) {
for(int i = 0; i < 4; ++i) {
SPVertex & vtx = render.getVertex(v+i);
for(int i = 0; i < 4; ++i) {
SPVertex & vtx = render.getVertex(v+i);
if (gDP.otherMode.depthSource == G_ZS_PRIM)
vtx.z = gDP.primDepth.z * vtx.w;
}
if (gSP.viewport.vscale[0] < 0)
vtx.x = -vtx.x;
}
if (gSP.matrix.billboard)
@ -552,6 +553,9 @@ void gSPProcessVertex(u32 v)
if (gDP.otherMode.depthSource == G_ZS_PRIM)
vtx.z = gDP.primDepth.z * vtx.w;
if (gSP.viewport.vscale[0] < 0)
vtx.x = -vtx.x;
if (gSP.matrix.billboard) {
int i = 0;
#ifdef __TRIBUFFER_OPT
@ -742,7 +746,7 @@ void gSPViewport( u32 v )
gSP.viewport.x = gSP.viewport.vtrans[0] - gSP.viewport.vscale[0];
gSP.viewport.y = gSP.viewport.vtrans[1] - gSP.viewport.vscale[1];
gSP.viewport.width = gSP.viewport.vscale[0] * 2;
gSP.viewport.width = fabs(gSP.viewport.vscale[0]) * 2;
gSP.viewport.height = fabs(gSP.viewport.vscale[1] * 2);
gSP.viewport.nearz = gSP.viewport.vtrans[2] - gSP.viewport.vscale[2];
gSP.viewport.farz = (gSP.viewport.vtrans[2] + gSP.viewport.vscale[2]) ;