diff --git a/GL/draw.c b/GL/draw.c index b7a76ec..b68e0c5 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -811,6 +811,7 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei genTriangleStrip(_glSubmissionTargetStart(target), count); break; default: + fprintf(stderr, "Unhandled mode %d\n", (int) mode); assert(0 && "Not Implemented"); } @@ -977,9 +978,12 @@ static void divide(SubmissionTarget* target) { Vertex* vertex = _glSubmissionTargetStart(target); ITERATE(target->count) { - vertex->xyz[2] = 1.0f / vertex->w; - vertex->xyz[0] *= vertex->xyz[2]; - vertex->xyz[1] *= vertex->xyz[2]; + // fprintf(stderr, "%f %f %f -> ", vertex->xyz[0], vertex->xyz[1], vertex->xyz[2]); + vertex->xyz[0] /= vertex->w; + vertex->xyz[1] /= vertex->w; + vertex->xyz[2] /= vertex->w; + vertex->xyz[2] = (DEPTH_RANGE_MULTIPLIER_L * (1.0f / vertex->xyz[2])) + DEPTH_RANGE_MULTIPLIER_H; + // fprintf(stderr, "%f %f %f %f\n", vertex->xyz[0], vertex->xyz[1], vertex->xyz[2], vertex->w); ++vertex; } } diff --git a/GL/matrix.c b/GL/matrix.c index 2de3e38..a40e7ca 100644 --- a/GL/matrix.c +++ b/GL/matrix.c @@ -15,7 +15,8 @@ static GLfloat gl_viewport_scale[3], gl_viewport_offset[3]; /* Depth range */ -static GLclampf gl_depthrange_near, gl_depthrange_far; +GLfloat DEPTH_RANGE_MULTIPLIER_L = (1 - 0) / 2; +GLfloat DEPTH_RANGE_MULTIPLIER_H = (0 + 1) / 2; /* Viewport size */ static GLint gl_viewport_x1, gl_viewport_y1, gl_viewport_width, gl_viewport_height; @@ -316,8 +317,8 @@ void APIENTRY glDepthRange(GLclampf n, GLclampf f) { if(f < 0.0f) f = 0.0f; else if(f > 1.0f) f = 1.0f; - gl_depthrange_near = n; - gl_depthrange_far = f; + DEPTH_RANGE_MULTIPLIER_L = (f - n) / 2.0f; + DEPTH_RANGE_MULTIPLIER_H = (n + f) / 2.0f; } /* Vector Cross Product - Used by glhLookAtf2 */ diff --git a/GL/private.h b/GL/private.h index ee78b3d..36e898a 100644 --- a/GL/private.h +++ b/GL/private.h @@ -195,6 +195,9 @@ void _glMatrixLoadModelView(); void _glMatrixLoadTexture(); void _glApplyRenderMatrix(); +extern GLfloat DEPTH_RANGE_MULTIPLIER_L; +extern GLfloat DEPTH_RANGE_MULTIPLIER_H; + matrix_t* _glGetProjectionMatrix(); matrix_t* _glGetModelViewMatrix(); diff --git a/GL/state.c b/GL/state.c index 2e718bf..f927c54 100644 --- a/GL/state.c +++ b/GL/state.c @@ -421,7 +421,6 @@ GLAPI void APIENTRY glReadBuffer(GLenum mode) { GLAPI void APIENTRY glDepthMask(GLboolean flag) { GL_CONTEXT.depth.write = (flag == GL_TRUE) ? PVR_DEPTHWRITE_ENABLE : PVR_DEPTHWRITE_DISABLE; - GL_CONTEXT.depth.comparison = _calc_pvr_depth_test(); } GLAPI void APIENTRY glDepthFunc(GLenum func) {