[106-107] Esoteric Calligraphy
- Conlan Walker
- Dec 1, 2023
- 1 min read
This one will be shorter, as I'm getting a bit busier.
Basically, last week was spent learning more c++, by using operator overloading to make something resembling a new primitive data type.
The data type is a 24-bit fixed point number, with 8-bits of fraction.
The operator overloading is used to theoretically make its semantics and syntax more or less identical to that of a float.
The use case I came up with is a software renderer that solely uses this fixed point data type, in the form of a simple triangle rasterizer (I didn't get around to making the extra overhead, like a .obj parser, or making a proprietary storage method, so it's just arbitrary triangles for now.)

The rasterizer works by recording the edges of the triangle, created by interpolating along the y axis as its input.
Here, the triangle's row edges are highlighted, rather than it being filled like it otherwise would.
Magenta denotes the start of a row, with cyan being the row's end.

This is that same triangle, filled in normally, with a magenta color.

To prevent overdraw, the last row and column of each row is removed.
This demo was one of the steps in (more or less) confirming that this overdraw prevention works.
When I say "overdraw", I mean that no pixel is drawn over where it shouldn't be. In this case, no edge is to be drawn twice.
And here's the boring code that nobody reads anyway:
(IMPORTANT: _fx16_8_sin_table is a huge lookup table, but for some reason pastebin doesn't want to show it)
(this is the actual rasterizer part)
Comments