top of page
Search

[80] Align; Pack, Set

  • Writer: Conlan Walker
    Conlan Walker
  • Apr 27, 2023
  • 2 min read

SDL's renderer could probably be used in some cool ways, but its limitations are, well, limiting.

It might be considerably slower, but I'm going to finally try out a fully software-based solution.


This does however require me to effectively tear apart everything related to TTM loading and handling, so refactoring was the main thing that occupied my time.

No cool triangles on-screen yet, but that doesn't mean nothing was done.

The Most noticeable differences are in the header file, with a completely reworked architecture of the TTM struct itself and its derivatives:

And for the rest of the TTM parser and loader stuff currently done (though not finished):


One thing that does stand out to me as being interesting, is a solution to a problem I thought was clever. The simple problem is that of resetting a z-buffer to the highest possible value I can at the start of rendering a frame. This could be done with a for loop of setting each element of the float array to 1e20 or something, but I wanted to see if there was a faster way that was even easier do implement.

My mind gravitated to memset, as it's a really fast way of setting all bytes of some memory to a single value, with the only drawback being that you can only choose an 8-bit value for everything. I eventually tinkered with this tool I found to find the highest float value that is just a single byte repeated 4 times (that isn't just a NaN), and came up with this:

ree

So now I should in theory be able to do a single "memset(zBuffer, 0x7f, sizeof(float) * w*h)" to set all of the z buffer's float values to a stupidly high number. Neat, huh?

 
 
 

Comments


bottom of page