Revert to more traditional GL depth values to fix ortho
This commit is contained in:
parent
17db29142a
commit
29658ef3de
14
GL/draw.c
14
GL/draw.c
|
@ -939,24 +939,12 @@ GL_FORCE_INLINE void divide(SubmissionTarget* target) {
|
|||
/* Perform perspective divide on each vertex */
|
||||
Vertex* vertex = _glSubmissionTargetStart(target);
|
||||
|
||||
/* PVR expects with invW or invZ as the final depth coordinate,
|
||||
* but there are issues with that. Using invW means that orthographic
|
||||
* projections fail (because W is always 1). invZ fails when stuff is near
|
||||
* the near plane (because it ends up <= 0) so what we do is take invZ
|
||||
* and add the near-plane distance (plus an epsilon value) to take it above 0
|
||||
* then invert that. */
|
||||
|
||||
Matrix4x4* proj = _glGetProjectionMatrix();
|
||||
float m22 = (*proj)[10];
|
||||
float m32 = (*proj)[14];
|
||||
float zNear = MATH_Fast_Divide((2.0f * m32), (2.0f * m22 - 2.0f));
|
||||
|
||||
ITERATE(target->count) {
|
||||
float f = MATH_Fast_Invert(vertex->w);
|
||||
vertex->xyz[0] *= f;
|
||||
vertex->xyz[1] *= f;
|
||||
vertex->xyz[2] = MATH_Fast_Invert(
|
||||
vertex->xyz[2] + zNear + 0.05f
|
||||
(vertex->xyz[2] * f) * 0.5f + 0.55f
|
||||
);
|
||||
++vertex;
|
||||
}
|
||||
|
|
|
@ -31,3 +31,4 @@ all:
|
|||
$(KOS_MAKE) -C mipmap all
|
||||
$(KOS_MAKE) -C lights all
|
||||
$(KOS_MAKE) -C depth_funcs_alpha_testing
|
||||
$(KOS_MAKE) -C depth_funcs_ortho
|
||||
|
|
|
@ -30,7 +30,8 @@ void ReSizeGLScene(int Width, int Height)
|
|||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
//gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);
|
||||
glOrtho(0.0, 640.0, 0.0, 480.0, 0.0, 1.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user