Handle depth range (zmin, zmax) in a hackish way

This commit is contained in:
Florent Castelli 2012-11-25 00:15:21 +01:00
parent f71d82fc6e
commit 4143801891
3 changed files with 19 additions and 8 deletions

View File

@ -588,12 +588,14 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff)
}
break;
case GE_CMD_MINZ:
DEBUG_LOG(G3D, "DL MinZ: %i", data);
case GE_CMD_MINZ:
gstate_c.zMin = getFloat24(data) / 65535.f;
DEBUG_LOG(G3D, "DL MinZ: %i", gstate_c.zMin);
break;
case GE_CMD_MAXZ:
DEBUG_LOG(G3D, "DL MaxZ: %i", data);
case GE_CMD_MAXZ:
gstate_c.zMax = getFloat24(data) / 65535.f;
DEBUG_LOG(G3D, "DL MaxZ: %i", gstate_c.zMax);
break;
case GE_CMD_FRAMEBUFPTR:
@ -850,12 +852,18 @@ void GLES_GPU::ExecuteOp(u32 op, u32 diff)
case GE_CMD_VIEWPORTX1:
case GE_CMD_VIEWPORTY1:
case GE_CMD_VIEWPORTZ1:
case GE_CMD_VIEWPORTX2:
case GE_CMD_VIEWPORTY2:
case GE_CMD_VIEWPORTZ2:
DEBUG_LOG(G3D,"DL Viewport param %i: %f", cmd-GE_CMD_VIEWPORTX1, getFloat24(data));
break;
case GE_CMD_VIEWPORTZ1:
gstate_c.zScale = getFloat24(data) / 65535.f;
DEBUG_LOG(G3D,"DL Z scale: %f", gstate_c.zScale);
break;
case GE_CMD_VIEWPORTZ2:
gstate_c.zOff = getFloat24(data) / 65535.f;
DEBUG_LOG(G3D,"DL Z pos: %f", gstate_c.zOff);
break;
case GE_CMD_LIGHTENABLE0:
case GE_CMD_LIGHTENABLE1:
case GE_CMD_LIGHTENABLE2:

View File

@ -557,6 +557,8 @@ void TransformAndDrawPrim(void *verts, void *inds, int prim, int vertexCount, Li
glstate.depthFunc.set(ztests[depthTestFunc]);
}
glstate.depthRange.set(gstate_c.zOff - gstate_c.zScale, gstate_c.zOff + gstate_c.zScale);
glEnableVertexAttribArray(program->a_position);
if (useTexCoord && program->a_texcoord != -1) glEnableVertexAttribArray(program->a_texcoord);
if (program->a_color0 != -1) glEnableVertexAttribArray(program->a_color0);

View File

@ -260,8 +260,9 @@ struct GPUStateCache
bool textureChanged;
float uScale,vScale;
float uOff,vOff;
float uScale,vScale,zScale;
float uOff,vOff,zOff;
float zMin, zMax;
float lightpos[4][3];
float lightdir[4][3];
float lightatt[4][3];