Search
lxdream.org :: lxdream/src/pvr2/rendsort.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/rendsort.c
changeset 331:a6048d3a9a79
prev319:5392aed6a982
next429:e581b90c3fb3
author nkeynes
date Fri Jan 26 01:37:39 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Z should be rendered as 1/Z - fixes a host of depth issues
file annotate diff log raw
1.1 --- a/src/pvr2/rendsort.c Wed Jan 24 08:11:14 2007 +0000
1.2 +++ b/src/pvr2/rendsort.c Fri Jan 26 01:37:39 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: rendsort.c,v 1.4 2007-01-24 08:11:14 nkeynes Exp $
1.6 + * $Id: rendsort.c,v 1.5 2007-01-26 01:37:39 nkeynes Exp $
1.7 *
1.8 * PVR2 renderer routines for depth sorted polygons
1.9 *
1.10 @@ -72,8 +72,11 @@
1.11 triangle[i].maxx = MAX3(triangle[i].vertexes[0][0],triangle[i].vertexes[1][0],triangle[i].vertexes[2][0]);
1.12 triangle[i].miny = MIN3(triangle[i].vertexes[0][1],triangle[i].vertexes[1][1],triangle[i].vertexes[2][1]);
1.13 triangle[i].maxy = MAX3(triangle[i].vertexes[0][1],triangle[i].vertexes[1][1],triangle[i].vertexes[2][1]);
1.14 - triangle[i].minz = MIN3(triangle[i].vertexes[0][2],triangle[i].vertexes[1][2],triangle[i].vertexes[2][2]);
1.15 - triangle[i].maxz = MAX3(triangle[i].vertexes[0][2],triangle[i].vertexes[1][2],triangle[i].vertexes[2][2]);
1.16 + float az = 1/triangle[i].vertexes[0][2];
1.17 + float bz = 1/triangle[i].vertexes[1][2];
1.18 + float cz = 1/triangle[i].vertexes[2][2];
1.19 + triangle[i].minz = MIN3(az,bz,cz);
1.20 + triangle[i].maxz = MAX3(az,bz,cz);
1.21 }
1.22 }
1.23
1.24 @@ -178,6 +181,8 @@
1.25 int i,j, k, m = 0;
1.26 for( i=0; i<num_triangles; i++ ) {
1.27 render_set_context( triangles[i].polygon, render_mode );
1.28 + glEnable(GL_DEPTH_TEST);
1.29 + glDepthFunc(GL_GEQUAL);
1.30 if( triangles[i].vertex_length == 0 ) {
1.31 render_unpacked_vertex_array( *triangles[i].polygon, (struct vertex_unpacked **)triangles[i].vertexes, 3 );
1.32 } else {
1.33 @@ -193,10 +198,10 @@
1.34 {
1.35 struct render_triangle *tri1 = a;
1.36 struct render_triangle *tri2 = b;
1.37 - if( tri1->minz < tri2->minz ) {
1.38 + if( tri1->minz < tri2->minz ) {
1.39 + return 1; // No these _aren't_ back to front...
1.40 + } else if( tri1->minz > tri2->minz ) {
1.41 return -1;
1.42 - } else if( tri1->minz > tri2->minz ) {
1.43 - return 1;
1.44 } else {
1.45 return 0;
1.46 }
.