top of page
Search

[69] Omitting the Unbefitting

  • Writer: Conlan Walker
    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.



ree

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".

ree

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:

ree

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:

ree

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)

ree

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

ree

Now, time to actually try these out.



ree

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.)





ree


ree

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











ree


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.

ree

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

 
 
 

Comments


bottom of page