2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
24 #define POLYFILL_MODE_MASK 0x03
25 #define POLYFILL_TEX_BIT 0x04
26 #define POLYFILL_ALPHA_BIT 0x08
27 #define POLYFILL_ADD_BIT 0x10
28 #define POLYFILL_ZBUF_BIT 0x20
35 POLYFILL_TEX_WIRE = 4,
39 POLYFILL_ALPHA_WIRE = 8,
41 POLYFILL_ALPHA_GOURAUD,
43 POLYFILL_ALPHA_TEX_WIRE = 12,
44 POLYFILL_ALPHA_TEX_FLAT,
45 POLYFILL_ALPHA_TEX_GOURAUD,
47 POLYFILL_ADD_WIRE = 16,
51 POLYFILL_ADD_TEX_WIRE = 20,
52 POLYFILL_ADD_TEX_FLAT,
53 POLYFILL_ADD_TEX_GOURAUD,
56 POLYFILL_WIRE_ZBUF = 32,
58 POLYFILL_GOURAUD_ZBUF,
60 POLYFILL_TEX_WIRE_ZBUF = 36,
61 POLYFILL_TEX_FLAT_ZBUF,
62 POLYFILL_TEX_GOURAUD_ZBUF,
64 POLYFILL_ALPHA_WIRE_ZBUF = 40,
65 POLYFILL_ALPHA_FLAT_ZBUF,
66 POLYFILL_ALPHA_GOURAUD_ZBUF,
68 POLYFILL_ALPHA_TEX_WIRE_ZBUF = 44,
69 POLYFILL_ALPHA_TEX_FLAT_ZBUF,
70 POLYFILL_ALPHA_TEX_GOURAUD_ZBUF,
72 POLYFILL_ADD_WIRE_ZBUF = 48,
73 POLYFILL_ADD_FLAT_ZBUF,
74 POLYFILL_ADD_GOURAUD_ZBUF,
76 POLYFILL_ADD_TEX_WIRE_ZBUF = 52,
77 POLYFILL_ADD_TEX_FLAT_ZBUF,
78 POLYFILL_ADD_TEX_GOURAUD_ZBUF
81 typedef uint32_t gaw_pixel;
83 #define PACK_RGB(r, g, b) \
84 (0xff000000 | ((r) << 16) | ((g) << 8) | (b))
85 #define PACK_RGBA(r, g, b, a) \
86 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
87 #define UNPACK_R(pix) ((pix) & 0xff)
88 #define UNPACK_G(pix) (((pix) >> 8) & 0xff)
89 #define UNPACK_B(pix) (((pix) >> 16) & 0xff)
90 #define UNPACK_A(pix) ((pix) >> 24)
99 /* projected vertices for the rasterizer */
101 int32_t x, y; /* 24.8 fixed point */
102 int32_t u, v; /* 16.16 fixed point */
103 int32_t r, g, b, a; /* int 0-255 */
104 int32_t z; /* 0-65535 */
112 unsigned int xmask, ymask;
115 extern struct pimage pfill_fb;
116 extern struct pimage pfill_tex;
117 extern uint32_t *pfill_zbuf;
119 void polyfill_fbheight(int height);
121 void polyfill(int mode, struct pvertex *verts, int nverts);
123 void polyfill_wire(struct pvertex *verts, int nverts);
124 void polyfill_flat(struct pvertex *verts, int nverts);
125 void polyfill_gouraud(struct pvertex *verts, int nverts);
126 void polyfill_tex_wire(struct pvertex *verts, int nverts);
127 void polyfill_tex_flat(struct pvertex *verts, int nverts);
128 void polyfill_tex_gouraud(struct pvertex *verts, int nverts);
129 void polyfill_alpha_wire(struct pvertex *verts, int nverts);
130 void polyfill_alpha_flat(struct pvertex *verts, int nverts);
131 void polyfill_alpha_gouraud(struct pvertex *verts, int nverts);
132 void polyfill_alpha_tex_wire(struct pvertex *verts, int nverts);
133 void polyfill_alpha_tex_flat(struct pvertex *verts, int nverts);
134 void polyfill_alpha_tex_gouraud(struct pvertex *verts, int nverts);
135 void polyfill_add_wire(struct pvertex *verts, int nverts);
136 void polyfill_add_flat(struct pvertex *verts, int nverts);
137 void polyfill_add_gouraud(struct pvertex *verts, int nverts);
138 void polyfill_add_tex_wire(struct pvertex *verts, int nverts);
139 void polyfill_add_tex_flat(struct pvertex *verts, int nverts);
140 void polyfill_add_tex_gouraud(struct pvertex *verts, int nverts);
142 void polyfill_wire_zbuf(struct pvertex *verts, int nverts);
143 void polyfill_flat_zbuf(struct pvertex *verts, int nverts);
144 void polyfill_gouraud_zbuf(struct pvertex *verts, int nverts);
145 void polyfill_tex_wire_zbuf(struct pvertex *verts, int nverts);
146 void polyfill_tex_flat_zbuf(struct pvertex *verts, int nverts);
147 void polyfill_tex_gouraud_zbuf(struct pvertex *verts, int nverts);
148 void polyfill_alpha_wire_zbuf(struct pvertex *verts, int nverts);
149 void polyfill_alpha_flat_zbuf(struct pvertex *verts, int nverts);
150 void polyfill_alpha_gouraud_zbuf(struct pvertex *verts, int nverts);
151 void polyfill_alpha_tex_wire_zbuf(struct pvertex *verts, int nverts);
152 void polyfill_alpha_tex_flat_zbuf(struct pvertex *verts, int nverts);
153 void polyfill_alpha_tex_gouraud_zbuf(struct pvertex *verts, int nverts);
154 void polyfill_add_wire_zbuf(struct pvertex *verts, int nverts);
155 void polyfill_add_flat_zbuf(struct pvertex *verts, int nverts);
156 void polyfill_add_gouraud_zbuf(struct pvertex *verts, int nverts);
157 void polyfill_add_tex_wire_zbuf(struct pvertex *verts, int nverts);
158 void polyfill_add_tex_flat_zbuf(struct pvertex *verts, int nverts);
159 void polyfill_add_tex_gouraud_zbuf(struct pvertex *verts, int nverts);
161 void draw_line(struct pvertex *verts);
162 void draw_line_zbuf(struct pvertex *verts);
164 #endif /* POLYFILL_H_ */