Skip to content

timecomplexity/SDL3_Jumpstart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDL3 Jumpstart

Easy starting point for playing around with SDL3 and Vulkan, frankenstein'd from other projects.

Dependencies

CMake is our build tool of choice. Need to install at least version 3.26.

Download and build SDL3 which we will be using as our cross-platform window and input system. I cloned the latest release branch of SDL, changed into the root directory and ran the following (For Visual Studio 2022 on Windows). This will put all of the libraries into one place cleanly.

# Builds and installs Debug libraries
cmake -S . -B build/debug -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_BUILD_TYPE=Debug
cmake --build build/debug --target install --config Debug

# Builds and installs Release libraries
cmake -S . -B build/release -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_BUILD_TYPE=Release
cmake --build build/release --target install --config Release

We are using C++17. The following compilers are verified to work:

  • Visual Studio 2019
  • Visual Studio 2022
  • GCC 8
  • GCC 12

Setup

Vulkan

If using Vulkan, set up Vulkan using the installation process described here.

OpenGL

Build GLEW so we can use OpenGL. GLEW will be pulled down in the include/vendor directory. From the vendor directory:

(Note that it's probably best to reference the documentation on the repo for GLEW if these steps don't work.) We are using the cmake version of GLEW which can be found here.

cd glew/build
cmake ./cmake

# If you're on Linux, you can build from here
make -j4

On Windows, go into the build directory (include/vendor/glew/build) and open up the glew.sln project in visual studio. Compile each project for both Debug and Release x64. These files will appear under the bin directory in the glew project.

No need to install GLM which is included as a submodule.

Building

For the final step, there is also a provided build.sh script which only needs the named variables updated at the top of the script to match your generator and custom SDL3 install path.

By default OpenGL will be built, but Vulkan can be specified. This can be done using either of the following options when invoking CMake.

# Build for Vulkan
-DGRAPHICS_API=VULKAN

# Build for OpenGL
-DGRAPHICS_API=OPENGL

In order to build shaders for Vulkan, when invoking CMake you will need to supply the argument -DCOMPILE_SHADERS=1.

git clone --recurse-submodules https://github.com/timecomplexity/SDL3_Jumpstart.git
cd SDL3_Jumpstart

# Setup a shadow build
mkdir build && cd build

# Run CMake, replacing with appropriate values for your setup
cmake ../ -G <DesiredGenerator> -DGRAPHICS_API=<DesiredGraphicsAPI> -DCMAKE_BUILD_TYPE=<DesiredBuildConfiguration> -DCMAKE_PREFIX_PATH=<CustomSDLInstallLocation>
cmake --build . --config <DesiredBuildConfiguration>

# Example for Visual Studio 2022 and a custom install location for SDL3 in Release mode
cmake ../ -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="E:/SDL/install"
cmake --build . --config Release

About

Frankenstein'd project to jumpstart creating a project with SDL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published