GFX: Possible fix for depth range

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4044 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox
2009-08-24 06:48:00 +00:00
parent 689036c59c
commit 1427024a21
3 changed files with 18 additions and 16 deletions

View File

@ -181,6 +181,8 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
// Init functions
bool Renderer::Init()
{
xfregs.depthRangeConst[0] = 16777216.0f;
xfregs.depthRangeConst[1] = 16777216.0f;
bool bSuccess = true;
s_blendMode = 0;
s_MSAACoverageSamples = 0;
@ -1446,14 +1448,11 @@ void UpdateViewport()
int GLy = (int)ceil(Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4] - xfregs.rawViewport[1] - 342 - scissorYOff)) * MValueY);
int GLWidth = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX);
int GLHeight = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY);
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / xfregs.depthRangeConst[0];
double GLFar = xfregs.rawViewport[5] / xfregs.depthRangeConst[1];
// Update the view port
glViewport(GLx, GLy, GLWidth, GLHeight);
// GLDepthRange - this could be a source of trouble - see the viewport hacks.
// TODO : Should this use 16777216.0f or 16777215.0f ?
double GLNear = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777215.0f;
double GLFar = xfregs.rawViewport[5] / 16777215.0f;
glDepthRange(GLNear, GLFar);
// -------------------------------------