|||

back

July 31st 2024

Learning SDL2

Introduction

Coming in to week 3 and studio 5, I had no idea what SDL2 is how to use some of the functions. We were thankfully provided some resources on learning some basics of SDL2. For leanring the basics of creating a window and loading bmp files, I followed the first two tutorials from thenum.at.

Reflection

During the setup process, it took some time as I was on MacOS and using CLion for development. The installation process was quite cumbersome as you had to drag the files to the framework folder in finder then, add it as dependencies in the CMake files for CLion to properly import and link.

While I only completed two task from the tutorial, I think that I have a basic understanding of how basic window creation and bitmap loading works.

SDL2 - 01 Creating a window

Following this tutorial, I was successful in creating my first window using SDL2. The window included drawing a color filled reactangle which filled the entire window creating a red background.

SDL2 01

Completing this was somewhat confusing as it was my first time using SDL2. What I love about this website is that there are comments and comprehensive explainations on the side which explained bits of the code and what it does. I feel like the inclusion of the explaintions was very helpful to understand the concepts of creating a window using SDL2.

SDL2 - 02

After completing the first tutorial I decided to continue on to the second one which was working with bitmaps. The goal of tutorial 2 was to create a window and load in two bitmap images.

I initially had some troubles with loading the bitmaps into the window. It turns out one of the files was missing a letter so the program couldn't find the source. Once I did fix the naming issue however, everything worked and two images was displayed in the window.

SDL2 02