Skip to content

graysonpike/sdlgl

Repository files navigation

sdlgl

An SDL3 Game Library

This is a simple game framework library I'm creating for use in my own games. SDLGL currently provides support for

  • A simple and extensible Entity + Scene organization
  • A simple 'Update and Render' game loop
  • Audio mixing for sound effects and music built on miniaudio
  • Easily configurable (JSON-defined) resources supporting:
    • Animated sprites
    • Static textures
    • Sound effects
    • Music tracks
  • Collision detection system for rotatable rectangles
  • Font renderer
  • Debugging UI elements
  • Access to the SDL3 rendering context
  • Multiple example programs demonstrating each engine feature

Demo Projects

In addition to the example programs, I have some other projects that are built with SDLGL.

Knight game gameplay

Perlin noise waves simulation

Tank game gameplay

Dependencies

To install SDLGL, you will have to build from source. Before building, there are 3 dependencies required for static linking:

  • SDL3
  • SDL3_image
  • SDL3_ttf

Installing Dependencies on Linux (Debian/Ubuntu)

You can build SDL3, SDL3_image, and SDL3_ttf from source. See the official SDL3 documentation for instructions.

MacOS

You can use homebrew to install the libraries.

brew install sdl3 sdl3_image sdl3_ttf

Building and Installation

Currently, no binaries are published for SDLGL. A CMake configuration is provided to enable easy building across platforms. SDL3 ships with CMake config files, so no custom Find modules are needed.

The recommended way to use SDLGL is via CMake add_subdirectory. In your project's CMakeLists.txt:

add_subdirectory(path/to/sdlgl ${CMAKE_BINARY_DIR}/sdlgl)
target_link_libraries(YourProject PRIVATE sdlgl)

This automatically brings in SDL3, SDL3_image, and SDL3_ttf as transitive dependencies.

Alternatively, you can build and install the library system-wide:

cmake -S . -B build
cmake --build build
cmake --install build --prefix ~/.local

Development

Additional Development Requirements

In addition to the build requirements, additional tools are required for development. You can install them with the following commands:

Linux (Debian/Ubuntu)

sudo apt install clang-format

macOS

brew install clang-format

Formatting

This project is auto-formatted to the Google style (modified to an indent of 4 spaces) using the clang-format tool.

To run the auto-formatter on all files, use the following command:

bash clang_format_project.sh

License

SDLGL is licensed under the MIT License.

This library uses the JSON C++ library by Niels Lohmann which is licensed under the MIT License.

About

A 2D Game Library Built on SDL2

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages