[69] Omitting the Unbefitting
- Conlan Walker

- Feb 10, 2023
- 2 min read
This week focused on SDL_image, textures by extension, and some more stuff related to SDL renderer functions. I ended up not doing much on Monday besides setting up SDL_image, which I compiled previously, so it was even easier than it would be otherwise.

The next thing I wanted to do is quickly see if I did everything correctly. I proved that I did by putting this image on-screen.
I found this somewhere in my downloads, and I think It's from an older Touhou game, not only because the filename is "2hu.png".

As you can see, you really don't need much code to accomplish this. The screenshot above is everything that went into blitting this to a window.
Next, I wanted to figure out how to use the new SDL_RenderGeometry() function, as it allows for texture-mapped triangles and gradients.
This test demonstrates arbitrary triangle drawing using a crudely-drawn Yotsuba as a texture:
This next demonstrates the usage of vertex color components, which double as color/alpha modulators when using a texture:
The last of the C demos is just showing a moving color gradient, without using a texture:
The Lua bindings are as follows:
This is the single SDL_image binding I've made, and hopefully will have to make:

It isn't much, as all SDL_image does is provide some loaders and check functions for various image formats. Since I want to (if at all possible) solely use .png for images, this function should be the only one relevant to me.
The images loaded using SDL_image come in the form of SDL textures, so I implemented some functions that alter those textures in various ways:

The last two I want to show are renderer related. This one's the binding for SDL_RenderCopyEx():
(I also did one for SDL_RenderCopy, but I'm not showing it here, as they're very similar, and RenderCopyEx is already a sort of superset of RenderCopy)

Finally, this is SDL_RenderGeometry, which is the function that was the greatest pain to make:

Now, time to actually try these out.

The 1st demo is really simple, as again I just wanted to get something on-screen to make sure everything was working properly.
(This one uses RenderCopy, not RenderCopyEx or RenderGeometry.)


The 2nd one uses RenderCopyEx, which allows for rotation, and horizontal/vertical mirroring.

The 3rd one uses RenderGeometry, though none of its color/alpha modulation capabilities:
The last one does a few things, but mainly showcases RenderGeometry's color/alpha modulation for textures:
Finally, this is the size of everything as it stands now.

Next week, I'll focus on input, namely joysticks/controller stuff. Also, some stuff related to a raycasting engine if possible.

![[158] Most Important Brick in the Least Important Wall](https://static.wixstatic.com/media/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg/v1/fill/w_980,h_410,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_f70be6ae4318455fbbc605cd1069c6ee~mv2.jpg)
![[157] Mail Order Sacrifice](https://static.wixstatic.com/media/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png/v1/fill/w_980,h_382,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_e284fa6c51b04524bab9d3cf9f1f6441~mv2.png)
![[156] Moat of Babble](https://static.wixstatic.com/media/df100d_091e451794b14aecb494a16c15c966c3~mv2.png/v1/fill/w_980,h_705,al_c,q_90,usm_0.66_1.00_0.01,enc_avif,quality_auto/df100d_091e451794b14aecb494a16c15c966c3~mv2.png)
Comments