X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fpolyfill.c;h=634d525602eef240d4c12ca013e1a9d3600c0fc2;hb=6218ea71a2a175dca5bf88ca7922e97f42f85e69;hp=79d1d69ce0cee61da8450aa34b5fdd6aaad054ea;hpb=0945eeeef21fe85f9a592bfc2e41069a7894b08b;p=dosdemo diff --git a/src/polyfill.c b/src/polyfill.c index 79d1d69..634d525 100644 --- a/src/polyfill.c +++ b/src/polyfill.c @@ -1,5 +1,12 @@ #include #include +#include +#include +#if defined(__WATCOMC__) || defined(_MSC_VER) +#include +#else +#include +#endif #include "polyfill.h" #include "gfxutil.h" #include "demo.h" @@ -7,7 +14,9 @@ void (*fillfunc[])(struct pvertex*, int) = { polyfill_wire, polyfill_flat, - 0, 0, 0 + polyfill_gouraud, + polyfill_tex, + polyfill_tex_gouraud }; struct pimage pimg_fb, pimg_texture; @@ -51,79 +60,34 @@ void polyfill_wire(struct pvertex *verts, int nverts) #define NEXTIDX(x) (((x) - 1 + nverts) % nverts) #define PREVIDX(x) (((x) + 1) % nverts) -#define CALC_EDGE(which) \ - do { \ - which##_x = pv[which##_beg].x; \ - which##_dx = pv[which##_end].x - pv[which##_beg].x; \ - which##_slope = (which##_dx << 8) / which##_dy; \ - } while(0) - -void polyfill_flat(struct pvertex *pv, int nverts) -{ - int i, sline, x, slen, top = 0; - int left_beg, left_end, right_beg, right_end; - int32_t left_dy, left_dx, right_dy, right_dx; - int32_t left_slope, right_slope; - int32_t left_x, right_x, y; - uint16_t color = ((pv->r << 8) & 0xf800) | ((pv->g << 3) & 0x7e0) | - ((pv->b >> 3) & 0x1f); - uint16_t *pixptr; - - /* find topmost */ - for(i=1; i> 8; - - for(;;) { - if(y >= pv[left_end].y) { - while(y >= pv[left_end].y) { - left_beg = left_end; - if(left_beg == right_beg) return; - left_end = PREVIDX(left_end); - } - - left_dy = pv[left_end].y - pv[left_beg].y; - CALC_EDGE(left); - } - - if(y >= pv[right_end].y) { - while(y >= pv[right_end].y) { - right_beg = right_end; - if(left_beg == right_beg) return; - right_end = NEXTIDX(right_end); - } - - right_dy = pv[right_end].y - pv[right_beg].y; - CALC_EDGE(right); - } - - x = left_x >> 8; - slen = (right_x >> 8) - (left_x >> 8); - - pixptr = pimg_fb.pixels + sline * pimg_fb.width + x; - for(i=0; i