Learning about SDL2


When my partner and I were looking for a development library to use in order to render the emulator graphically Emulator 101 didn’t really show any options for Windows development, which a platform that both of us had access to. Emulator 101 focus on showing how to develop the emulator for use on MacOS and iOS, so while it would show us some of the logic it would be unable to get the program working for Windows. During one of our weekly sprint meetings we looked at many options and stumbled upon SDL2, which is version 2 of SDL.

SDL, or Simple DirectMedia Layer, is “a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D” [1]. SDL basically acts as the link between the platform specific functionality that a program needs to access and the program itself. This was exactly what we needed since for the machine we needed to emulate the audio, the graphics, and the I/O that will connect the machine to the output devices on the platform. One other benefit of SDL2 is that it is “written in C” and “works natively with C++” [2]. This makes it simple for us to integrate with our emulator program that we started coding in C. We did choose C++ for the machine implementation for the ease of implementation, but because C integrates with C++ programs easily and SDL can handle both languages, this was not an issue for us.

Some examples of games that use SDL are Amnesia: The Dark Descent and FTL: Faster than Light and VVVVVV. These are three completely different games in scale, but they all still benefit from the use of SDL for use on PC platforms in some way. Depending on the type of game, SDL is the main development library a game depends on (i.e. VVVVVV, as shown in the source code [3]), while some games mainly use it for parts of their program like just the I/O handling (i.e. Amnesia: The Dark Descent).

SDL is an industry standard for many games due to the simplicity of implementation as well as the compatibility between platforms. As someone who has played or has seen the games that the SDL development library is used in, it’s impressive to see how flexible the library is when it comes to integration with a game, no matter how big or how small the use case for SDL is.

Reference:

[1] “SDL Library in C/C++ with examples,” GeeksforGeeks, 15-Feb-2022. [Online]. Available: https://www.geeksforgeeks.org/sdl-library-in-c-c-with-examples/. [Accessed: 10-Nov-2022].

[2] “About SDL,” Simple DirectMedia Layer – Homepage. [Online]. Available: https://www.libsdl.org/. [Accessed: 10-Nov-2022].

[3] TerryCavanagh, “Terrycavanagh/VVVVVV: The source code to VVVVVV! http://thelettervsixtim.es/,” GitHub. [Online]. Available: https://github.com/TerryCavanagh/VVVVVV. [Accessed: 10-Nov-2022].

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *