RE: https://mastodon.gamedev.place/@eniko/116232581608004216

instead of dealing with any of that i spent the afternoon refactoring so that i can include my library multiple times with different suffixes. this will be useful for supporting different color bit depths and such without making my code completely impossible to maintain

i was looking at 9 functions

1. flat color
2. gouraud
3. luminance grayscale
4. luminance with color ramp
5. textured
6. textured with flat color
7. textured with gouraud
8. textured with luminance grayscale
9. textured with luminance with color ramp

times 6 color depths (32, 24, 16 555 & 565, 8 332 and 8 bits with CLUT) is 54

(times two for depth buffer is 108)

now instead it can just be one include per desired supported mode

@eniko I wonder if instead of all the combinations you could make the triangle function an iterator, then use composition:
```
struct tri_iter iter = make_iter(triangle);
struct tri_iter_data = TRI_ITER_DATA_ZERO;
while tri_iter_next(&iter, &texel_data) {
struct rgb8 c = sample_tex2(tex, texel_data.uv);
c = lighting(c, light, lerp2(texel_data.uv, …));
buffer[texel_data.index] = rgba8_to_rgb555(c);
}
```
@bnut i *could* do that, but it would almost certainly be much slower? if only for the iterator logic
@eniko Not sure, it definitely puts more work on the compiler’s optimiser, but depending on what your logic was and with inlining it may be similar. Although if the #define method works then that’s great :) it’s a pity C doesn’t have closures.
@eniko it’d likely make dithering harder though