lxdream.org :: lxdream :: r650:80568a7a1ec7
lxdream 0.9.1
released Jun 29
 changeset 650:80568a7a1ec7 lxdream-render parent 649:620c5c6496b5 child 651:95a9cf98785b author nkeynes date Sun Mar 16 04:49:19 2008 +0000 (14 years ago) branch lxdream-render
Use max-z rather than min-z for tri sort (still wrong for some cases of course,
but consistent with prior behaviour)
```     1.1 --- a/src/pvr2/rendsort.c	Tue Mar 11 08:50:16 2008 +0000
1.2 +++ b/src/pvr2/rendsort.c	Sun Mar 16 04:49:19 2008 +0000
1.3 @@ -30,7 +30,7 @@
1.4  struct sort_triangle {
1.5      struct polygon_struct *poly;
1.6      int triangle_num; // triangle number in the poly, from 0
1.7 -    float minz;
1.8 +    float maxz;
1.9  };
1.10
1.12 @@ -66,7 +66,7 @@
1.13
1.14  /**
1.15   * Extract a triangle list from the tile (basically indexes into the polygon list, plus
1.16 - * computing minz while we go through it
1.17 + * computing maxz while we go through it
1.18   */
1.19  int sort_extract_triangles( pvraddr_t tile_entry, struct sort_triangle *triangles )
1.20  {
1.21 @@ -98,7 +98,7 @@
1.22  		    struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
1.23  		    triangles[count].poly = poly;
1.24  		    triangles[count].triangle_num = 0;
1.25 -		    triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index].z,
1.26 +		    triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,
1.27  						  pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.28  						  pvr2_scene.vertex_array[poly->vertex_index+2].z );
1.30 @@ -113,13 +113,13 @@
1.31  		    struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
1.32  		    triangles[count].poly = poly;
1.33  		    triangles[count].triangle_num = 0;
1.34 -		    triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index].z,
1.35 +		    triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,
1.36  						  pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.37  						  pvr2_scene.vertex_array[poly->vertex_index+2].z );
1.38  		    count++;
1.39  		    triangles[count].poly = poly;
1.40  		    triangles[count].triangle_num = 1;
1.41 -		    triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.42 +		    triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+1].z,
1.43  						  pvr2_scene.vertex_array[poly->vertex_index+2].z,
1.44  						  pvr2_scene.vertex_array[poly->vertex_index+3].z );
1.45  		    count++;
1.46 @@ -133,7 +133,7 @@
1.47  		    if( entry & (0x40000000>>i) ) {
1.48  			triangles[count].poly = poly;
1.49  			triangles[count].triangle_num = i;
1.50 -			triangles[count].minz = MIN3( pvr2_scene.vertex_array[poly->vertex_index+i].z,
1.51 +			triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+i].z,
1.52  						      pvr2_scene.vertex_array[poly->vertex_index+i+1].z,
1.53  						      pvr2_scene.vertex_array[poly->vertex_index+i+2].z );
1.54  			count++;
1.55 @@ -155,7 +155,7 @@
1.56  	    glBindTexture(GL_TEXTURE_2D, poly->tex_id);
1.57  	}
1.58  	render_set_context( poly->context, RENDER_NORMAL );
1.59 -	glEnable(GL_DEPTH_TEST);
1.61  	glDepthFunc(GL_GEQUAL);
1.62  	/* Fix cull direction */
1.63  	if( triangles[i].triangle_num & 1 ) {
1.64 @@ -163,6 +163,7 @@
1.65  	} else {
1.66  	    glCullFace(GL_BACK);
1.67  	}
1.68 +
1.69  	glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i].triangle_num, 3 );
1.70      }
1.71  }
1.72 @@ -171,7 +172,7 @@
1.73  {
1.74      const struct sort_triangle *tri1 = a;
1.75      const struct sort_triangle *tri2 = b;
1.76 -    return tri2->minz - tri1->minz;
1.77 +    return tri2->maxz - tri1->maxz;
1.78  }
1.79
1.80  void sort_triangles( struct sort_triangle *triangles, int num_triangles )
1.81 @@ -191,7 +192,8 @@
1.82  	// Reserve space for num_triangles / 2 * 4 vertexes (maximum possible number of