X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fgaw%2Fpolyfill.c;h=e6a87f62a937b525f474e29320fb3db15980c5fb;hb=15a4548ff09afb37dd33786cafd50b060a64f840;hp=f0355c1baf4c4ac646dc8171c92e23599401e7cf;hpb=f0f09a5f3f76fd4207e4d2d71f29f876b2b379f7;p=retroray diff --git a/src/gaw/polyfill.c b/src/gaw/polyfill.c index f0355c1..e6a87f6 100644 --- a/src/gaw/polyfill.c +++ b/src/gaw/polyfill.c @@ -487,7 +487,7 @@ void draw_line_zbuf(struct pvertex *verts) int32_t x0, y0, x1, y1, z0, z1, z, dz, zslope; int i, dx, dy, x_inc, y_inc, error; uint32_t *fb = pfill_fb.pixels; - uint32_t *zptr; + uint32_t *zptr = pfill_zbuf; uint32_t color = PACK_RGB(verts[0].r, verts[0].g, verts[0].b); x0 = verts[0].x >> 8; @@ -498,7 +498,7 @@ void draw_line_zbuf(struct pvertex *verts) z1 = verts[1].z; fb += y0 * pfill_fb.width + x0; - zptr = pfill_zbuf + y0 * pfill_fb.width + x0; + zptr += y0 * pfill_fb.width + x0; dx = x1 - x0; dy = y1 - y0; @@ -517,8 +517,10 @@ void draw_line_zbuf(struct pvertex *verts) dy = -dy; } + z = z0; + if(dx > dy) { - zslope = dx ? (dz << 8) / dx : 0; + zslope = dx ? (dz << 8) / (verts[1].x - verts[0].x) : 0; error = dy * 2 - dx; for(i=0; i<=dx; i++) { if(z <= *zptr) { @@ -537,7 +539,7 @@ void draw_line_zbuf(struct pvertex *verts) z += zslope; } } else { - zslope = dy ? (dz << 8) / dy : 0; + zslope = dy ? (dz << 8) / (verts[1].y - verts[0].y) : 0; error = dx * 2 - dy; for(i=0; i<=dy; i++) { if(z <= *zptr) {