5 #if defined(__WATCOMC__) || defined(_MSC_VER) || defined(__DJGPP__)
13 #define FILL_POLY_BITS 0x03
15 /* mode bits: 00-wire 01-flat 10-gouraud 11-reserved
19 void (*fillfunc[])(struct pvertex*, int) = {
30 polyfill_blend_gouraud,
32 polyfill_blend_tex_wire,
33 polyfill_blend_tex_flat,
34 polyfill_blend_tex_gouraud,
38 struct pimage pfill_fb, pfill_tex;
40 void polyfill(int mode, struct pvertex *verts, int nverts)
44 fprintf(stderr, "polyfill mode %d not implemented\n", mode);
49 fillfunc[mode](verts, nverts);
52 void polyfill_wire(struct pvertex *verts, int nverts)
54 int i, x0, y0, x1, y1;
55 struct pvertex *v = verts;
56 unsigned short color = ((v->r << 8) & 0xf800) |
57 ((v->g << 3) & 0x7e0) | ((v->b >> 3) & 0x1f);
59 for(i=0; i<nverts - 1; i++) {
65 if(clip_line(&x0, &y0, &x1, &y1, 0, 0, pfill_fb.width, pfill_fb.height)) {
66 draw_line(x0, y0, x1, y1, color);
71 if(clip_line(&x1, &y1, &x0, &y0, 0, 0, pfill_fb.width, pfill_fb.height)) {
72 draw_line(x1, y1, x0, y0, color);
76 void polyfill_tex_wire(struct pvertex *verts, int nverts)
78 polyfill_wire(verts, nverts); /* TODO */
81 void polyfill_blend_wire(struct pvertex *verts, int nverts)
83 polyfill_wire(verts, nverts); /* TODO */
86 void polyfill_blend_tex_wire(struct pvertex *verts, int nverts)
88 polyfill_wire(verts, nverts); /* TODO */
91 #define NEXTIDX(x) (((x) - 1 + nverts) % nverts)
92 #define PREVIDX(x) (((x) + 1) % nverts)
95 * When HIGH_QUALITY is defined, the rasterizer calculates slopes for attribute
96 * interpolation on each scanline separately; otherwise the slope for each
97 * attribute would be calculated once for the whole polygon, which is faster,
98 * but produces some slight quantization artifacts, due to the limited precision
99 * of fixed-point calculations.
103 /* extra bits of precision to use when interpolating colors.
104 * try tweaking this if you notice strange quantization artifacts.
106 #define COLOR_SHIFT 12
109 #define POLYFILL polyfill_flat
110 #define SCANEDGE scanedge_flat
114 #include "polytmpl.h"
118 #define POLYFILL polyfill_gouraud
119 #define SCANEDGE scanedge_gouraud
123 #include "polytmpl.h"
127 #define POLYFILL polyfill_tex_flat
128 #define SCANEDGE scanedge_tex_flat
132 #include "polytmpl.h"
136 #define POLYFILL polyfill_tex_gouraud
137 #define SCANEDGE scanedge_tex_gouraud
141 #include "polytmpl.h"
145 #define POLYFILL polyfill_blend_flat
146 #define SCANEDGE scanedge_blend_flat
150 #include "polytmpl.h"
154 #define POLYFILL polyfill_blend_gouraud
155 #define SCANEDGE scanedge_blend_gouraud
159 #include "polytmpl.h"
163 #define POLYFILL polyfill_blend_tex_flat
164 #define SCANEDGE scanedge_blend_tex_flat
168 #include "polytmpl.h"
172 #define POLYFILL polyfill_blend_tex_gouraud
173 #define SCANEDGE scanedge_blend_tex_gouraud
177 #include "polytmpl.h"