X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fpolyfill.c;h=1393cd200fc0b1b1906f51236cf229adb966d344;hb=1fc50fb52faab54b3d5e160d3765d866c6cf173a;hp=634d525602eef240d4c12ca013e1a9d3600c0fc2;hpb=6218ea71a2a175dca5bf88ca7922e97f42f85e69;p=dosdemo diff --git a/src/polyfill.c b/src/polyfill.c index 634d525..1393cd2 100644 --- a/src/polyfill.c +++ b/src/polyfill.c @@ -2,7 +2,7 @@ #include #include #include -#if defined(__WATCOMC__) || defined(_MSC_VER) +#if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__DJGPP__) #include #else #include @@ -19,7 +19,7 @@ void (*fillfunc[])(struct pvertex*, int) = { polyfill_tex_gouraud }; -struct pimage pimg_fb, pimg_texture; +struct pimage pfill_fb, pfill_tex; void polyfill(int mode, struct pvertex *verts, int nverts) { @@ -46,13 +46,13 @@ void polyfill_wire(struct pvertex *verts, int nverts) ++v; x1 = v->x >> 8; y1 = v->y >> 8; - if(clip_line(&x0, &y0, &x1, &y1, 0, 0, pimg_fb.width, pimg_fb.height)) { + if(clip_line(&x0, &y0, &x1, &y1, 0, 0, pfill_fb.width, pfill_fb.height)) { draw_line(x0, y0, x1, y1, color); } } x0 = verts[0].x >> 8; y0 = verts[0].y >> 8; - if(clip_line(&x1, &y1, &x0, &y0, 0, 0, pimg_fb.width, pimg_fb.height)) { + if(clip_line(&x1, &y1, &x0, &y0, 0, 0, pfill_fb.width, pfill_fb.height)) { draw_line(x1, y1, x0, y0, color); } } @@ -60,6 +60,21 @@ void polyfill_wire(struct pvertex *verts, int nverts) #define NEXTIDX(x) (((x) - 1 + nverts) % nverts) #define PREVIDX(x) (((x) + 1) % nverts) +/* XXX + * When HIGH_QUALITY is defined, the rasterizer calculates slopes for attribute + * interpolation on each scanline separately; otherwise the slope for each + * attribute would be calculated once for the whole polygon, which is faster, + * but produces some slight quantization artifacts, due to the limited precision + * of fixed-point calculations. + */ +#define HIGH_QUALITY + +/* extra bits of precision to use when interpolating colors. + * try tweaking this if you notice strange quantization artifacts. + */ +#define COLOR_SHIFT 12 + + #define POLYFILL polyfill_flat #define SCANEDGE scanedge_flat #undef GOURAUD