Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /var/www/vhosts/bilgigunlugum.net/httpdocs/index.php on line 43
SDL Oyun Programlama

SDL3 Oyun Programlama sayfalarımız yayında...

Ana sayfa > Oyun programlama > SDL3 programming > SDL3 extensions installation

SDL3 extensions installation

CMake installation

CMake is a cross-platform and open source software used to convert applications developed in C or C++ into projects for any compiler.

We will use CMake to compile the library code built for SDL into a project that can be compiled with the CodeBlocks 20.03 32-bit IDE.

1. Download cmake-3.31.1-rc3-windows-x86_64.zip file from here and open it on our computer.

2. When we unzip the cmake file, a directory structure will be created as follows:

3. Let's edit the Windows PATH variable to include only the bin directory of the MingW compiler for compiling.

C:\Program Files (x86)\CodeBlocks\MinGW\bin

This edit will ensure that we use the same compiler as the CodeBlocks 20.03 32-bit compiler in the files that will be created by CMake.

SDL libraries

There are libraries that extend the basic functions of SDL.

You can access the web page includes SDL Libraries from here.

Although many of these libraries start with "SDL_", none of them are part of the core SDL library.

SDL_image library

Loads images onto SDL surfaces and textures. The supported image formats are as follows:

BMP, GIF, JPEG, LBM, PCX, PNG, PNM, SVG, TGA, TIFF, WEBP, XCF, XPM, XV

Links related to SDL_image library

Project page: https://github.com/libsdl-org/SDL_image

SDL Wiki: https://wiki.libsdl.org/SDL3_image/FrontPage

Latest version: https://github.com/libsdl-org/SDL_image/releases

Creating the SDL3_image.dll file

When we prepare this page, since the latest released version of the SDL_image library is 2.8.2 for SDL2 and there is no release for SDL3, we need to build the SDL3 version of this library from the source code.

1. Let's download the SDL_image-main.zip file from here and open it on our computer.

2. When we open the downloaded file on our computer, a directory structure will be created as follows:

3. Let's create a directory named build on our computer. This directory will be used to transfer the created project. Here, we create the directory just under the C: drive. You can create it in any section of your drive.

4. Let's run the cmake-gui.exe file and follow the steps below:

  • Let's add the path definition of the SDL_image-main directory to the "Where is the source code" section, and the path definition of the build directory to the "Where to build the binaries" section, and click the Configure button.
  • In the window that appears, while the Use default native compilers option is selected, let's select the CodeBlocks - MinGW Makefiles option from the box above and click the Finish button.
  • After the program performs some operations, let's close the warning window by clicking the OK button in the window that appears.
  • Clicking on the button on the right side of the line where the CMAKE CODE BLOCKS EXECUTABLE variable is located, select the CodeBlocks 20.03 32 bit .exe file (C:/Program Files (x86)/CodeBlocks/codeblocks.exe), clicking on the button on the right side of the line where the SDL3_DIR variable is located, select the cmake directory under the directory where the SDL3 program is installed (C:/SDL3/cmake) and select Configure button again.
  • Let's click on the Generate button on the screen similar to the one below, which shows that the configuration process is completed:
  • Creating a project The following screen appears, indicating that the process is complete:
  • Thus, a project file named SDL3_image.cbp that we will run with CodeBlocks 20.03 IDE is prepared in the build directory. A structure like the following will be created in the build directory under the C: drive:

4. Let's run the CodeBlocks 20.03 program and open the project named SDL3_image.cbp and perform the build process.

5. As a result of this process, the following files will be created in the build directory.

  • SDL3_image.dll
  • libSDL3_image.dll.a

6. Let's copy the SDL3_image.dll file in the build directory to the C:\SDL3-3.1.6\i686-w64-mingw32\bin directory, the libSDL3_image.dll.a file to the C:\SDL3-3.1.6\i686-w64-mingw32\lib directory, and the SDL3_image directory under the include directory in the SDL-image_main directory to the C:\SDL3-3.1.6\i686-w64-mingw32\include directory.

SDL_mixer library

SDL_mixer is a virtually portable audio mixing library used with the SDL library. It allows a programmer to use multiple samples with music without having to code a mixing algorithm. It also simplifies the process of loading and playing samples and music from any file format.

Links related to SDL_mixer library

Project page: https://github.com/libsdl-org/SDL_mixer

Latest version: https://github.com/libsdl-org/SDL_mixer/releases/tag/release-2.8.0

SDL3_mixer.dll file creation

When we prepare this page, since the latest released version of the SDL_image library is 2.8.0 for SDL2 and no version has been released for SDL3, we need to create the version of this library for SDL3 from the source codes.

1. Let's download the SDL_mixer-main.zip file from here and open it on our computer.

2. When we open the downloaded file on our computer, a directory structure will be created as follows:

3. Let's create a directory called build on our computer. This directory will be used to transfer the created project. Here, we create the directory just under the C: drive. You can create it in any section of your drive.

4. Let's run the cmake-gui.exe file and follow the steps below:

  • Let's add the path definition of the SDL_mixer-main directory to the "Where is the source code" section, and the path definition of the build directory to the "Where to build the binaries" section, and click the Configure button.
  • In the window that appears, while the Use default native compilers option is selected, let's select the CodeBlocks - MinGW Makefiles option from the box above and click the Finish button.
  • After the program has done some work, let's close the warning window by clicking OK in the window that appears.
  • Clicking on the button on the right side of the line where the CMAKE CODE BLOCKS EXECUTABLE variable is located, select the CodeBlocks 20.03 32 bit .exe file (C:/Program Files (x86)/CodeBlocks/codeblocks.exe), clicking on the button on the right side of the line where the SDL3_DIR variable is located, select the cmake directory under the directory where the SDL3 program is installed (C:/SDL3/cmake) and Configure button again.
  • Let's click on the Generate button on the screen similar to the one below, which shows that the configuration process is completed:
  • A screen similar to the one below appears indicating that the project creation process is complete:
  • Clicking on the button on the right side of the line where the CMAKE CODE BLOCKS EXECUTABLE variable is located, select the CodeBlocks 20.03 32 bit .exe file (C:/Program Files (x86)/CodeBlocks/codeblocks.exe), clicking on the button on the right side of the line where the SDL3_DIR variable is located, select the cmake directory (C:/SDL3/cmake) under the directory where the SDL3 program is installed, and click the Configure button again.
  • Let's click on the Generate button on the screen similar to the one below, which shows that the configuration process is completed:
  • A screen similar to the one below appears, indicating that the project creation process is complete:
  • Thus, a project file named SDL3_mixer.cbp that we will run with CodeBlocks 20.03 IDE is prepared in the build directory. A structure like the following will be created in the build directory under the C: drive:

4. Let's run the CodeBlocks 20.03 program and open the project named SDL3_mixer.cbp and perform the build process.

5. As a result of this process, the following files will be created in the build directory.

  • SDL3_mixer.dll
  • libSDL3_mixer.dll.a

6. Let's copy the SDL3_mixer.dll file in the build directory to the C:\SDL3-3.1.6\i686-w64-mingw32\bin directory, the libSDL3_mixer.dll.a file to the C:\SDL3-3.1.6\i686-w64-mingw32\lib directory, and the SDL3_mixer directory under the include directory in the SDL-mixer_main directory to the C:\SDL3-3.1.6\i686-w64-mingw32\include directory.