rasterize: fix viewport and perspective transformations. now triangles are rendered terribly in the correct place

This commit is contained in:
zeromus 2009-02-02 22:15:46 +00:00
parent fff695d3c1
commit 38d10282f4
1 changed files with 11 additions and 8 deletions

View File

@ -245,15 +245,18 @@ static void Render()
{ {
VERT &vert = gfx3d.vertlist->list[i]; VERT &vert = gfx3d.vertlist->list[i];
//perspective division ////perspective division
vert.coord[0] = (vert.coord[0] + vert.coord[3]) / 2 / vert.coord[3]; //vert.coord[0] = (vert.coord[0] + vert.coord[3]) / 2 / vert.coord[3];
vert.coord[1] = (vert.coord[1] + vert.coord[3]) / 2 / vert.coord[3]; //vert.coord[1] = (vert.coord[1] + vert.coord[3]) / 2 / vert.coord[3];
vert.coord[2] = (vert.coord[2] + vert.coord[3]) / 2 / vert.coord[3]; //vert.coord[2] = (vert.coord[2] + vert.coord[3]) / 2 / vert.coord[3];
vert.coord[3] = 1; //vert.coord[3] = 1;
//transform to viewport. this is badly broken ////transform to viewport. this is badly broken
vert.coord[0] = (vert.coord[0])*128; //vert.coord[0] = (vert.coord[0])*128;
vert.coord[1] = (vert.coord[1])*96; //vert.coord[1] = (vert.coord[1])*96;
vert.coord[0] = (vert.coord[0]+vert.coord[3])*256 / (2*vert.coord[3]) + 0;
vert.coord[1] = (vert.coord[1]+vert.coord[3])*192 / (2*vert.coord[3]) + 0;
int zzz=9; int zzz=9;
} }