10 /*#define DEBUG_OVERDRAW G3D_PACK_RGB(10, 10, 10)*/
17 void (*fillfunc[])(struct pvertex*) = {
23 polyfill_gouraud_zbuf,
24 polyfill_tex_flat_zbuf,
25 polyfill_tex_gouraud_zbuf
28 struct pimage pfill_fb, pfill_tex;
30 struct pgradient pgrad;
33 static struct pvertex *edgebuf, *left, *right;
34 static int edgebuf_size;
38 #define CHECKEDGE(x) \
41 assert(x < fbheight); \
47 void polyfill_fbheight(int height)
49 int newsz = (height * 2 + EDGEPAD * 3) * sizeof *edgebuf;
51 if(newsz > edgebuf_size) {
53 if(!(edgebuf = malloc(newsz))) {
54 fprintf(stderr, "failed to allocate edge table buffer (%d bytes)\n", newsz);
59 left = edgebuf + EDGEPAD;
60 right = edgebuf + height + EDGEPAD * 2;
63 memset(edgebuf, 0xaa, EDGEPAD * sizeof *edgebuf);
64 memset(edgebuf + height + EDGEPAD, 0xaa, EDGEPAD * sizeof *edgebuf);
65 memset(edgebuf + height * 2 + EDGEPAD * 2, 0xaa, EDGEPAD * sizeof *edgebuf);
72 void polyfill(int mode, struct pvertex *verts)
76 fprintf(stderr, "polyfill mode %d not implemented\n", mode);
81 fillfunc[mode](verts);
84 #define VNEXT(p) (((p) == varr + 2) ? varr : (p) + 1)
85 #define VPREV(p) ((p) == varr ? varr + 2 : (p) - 1)
86 #define VSUCC(p, side) ((side) == 0 ? VNEXT(p) : VPREV(p))
88 /* extra bits of precision to use when interpolating colors.
89 * try tweaking this if you notice strange quantization artifacts.
91 #define COLOR_SHIFT 12
94 #define POLYFILL polyfill_flat
101 #define POLYFILL polyfill_gouraud
105 #include "polytmpl.h"
108 #define POLYFILL polyfill_tex_flat
112 #include "polytmpl.h"
115 #define POLYFILL polyfill_tex_gouraud
119 #include "polytmpl.h"
122 /* ---- zbuffer variants ----- */
124 #define POLYFILL polyfill_flat_zbuf
128 #include "polytmpl.h"
131 #define POLYFILL polyfill_gouraud_zbuf
135 #include "polytmpl.h"
138 #define POLYFILL polyfill_tex_flat_zbuf
142 #include "polytmpl.h"
145 #define POLYFILL polyfill_tex_gouraud_zbuf
149 #include "polytmpl.h"