spine-sdl
The spine-sdl runtime provides functionality to load, manipulate and render Spine skeletal animation data using SDL. spine-sdl is based on spine-c and spine-cpp. Note that spine-c depends on spine-cpp, so both are required regardless of which API you choose to use.
See the spine-sdl documentation for in-depth information
Licensing
You are welcome to evaluate the Spine Runtimes and the examples we provide in this repository free of charge.
You can integrate the Spine Runtimes into your software free of charge, but users of your software must have their own Spine license. Please make your users aware of this requirement! This option is often chosen by those making development tools, such as an SDK, game toolkit, or software library.
In order to distribute your software containing the Spine Runtimes to others that don't have a Spine license, you need a Spine license at the time of integration. Then you can distribute your software containing the Spine Runtimes however you like, provided others don't modify it or use it to create new software. If others want to do that, they'll need their own Spine license.
For the official legal terms governing the Spine Runtimes, please read the Spine Runtimes License Agreement and Section 2 of the Spine Editor License Agreement.
Spine version
spine-sdl works with data exported from Spine 4.3.xx.
spine-sdl supports all Spine features except screen blend mode and two color tinting.
Usage
Integration with CMake (Recommended)
The easiest way to integrate spine-sdl into your project is via CMake FetchContent:
include(FetchContent)
FetchContent_Declare(
spine-sdl
GIT_REPOSITORY https://github.com/esotericsoftware/spine-runtimes.git
GIT_TAG 4.3
SOURCE_SUBDIR spine-sdl
)
FetchContent_MakeAvailable(spine-sdl)
# For C API
target_link_libraries(your_target spine-sdl-c)
# For C++ API
target_link_libraries(your_target spine-sdl-cpp)
This will automatically fetch and build spine-sdl along with its dependencies (spine-c, spine-cpp, and SDL).
Manual Integration
If you prefer manual integration:
- Download the Spine Runtimes source using git (
git clone https://github.com/esotericsoftware/spine-runtimes) or download it as a zip. - Add the required source files to your project:
- For C API: Add sources from
spine-cpp/src,spine-c/src, andspine-sdl/src/spine-sdl-c.c - For C++ API: Add sources from
spine-cpp/src,spine-c/src, andspine-sdl/src/spine-sdl-cpp.cpp
- For C API: Add sources from
- Add the include directories:
spine-cpp/include,spine-c/include, andspine-sdl/src - Link against SDL2
See the Spine Runtimes documentation for detailed API usage.
Examples
The repository includes example code for both C and C++ APIs:
- C example: example/main.c
- C++ example: example/main.cpp
Building the Examples
Windows
- Install Visual Studio Community. Make sure you install support for C++ and CMake.
- Download the Spine Runtimes repository using git (
git clone https://github.com/esotericsoftware/spine-runtimes) or download it as a zip. - Open Visual Studio Community, then open
spine-sdl/via the Open a local folder button in the Visual Studio Community launcher. - Wait for CMake to finish, then select either
spine-sdl-c-example.exeorspine-sdl-cpp-example.exeas the start-up project and start debugging.
Linux
- Install dependencies:
sudo apt-get install cmake ninja-build # Ubuntu/Debian # or equivalent for your distribution - Clone the repository:
git clone https://github.com/esotericsoftware/spine-runtimes - Build and run:
cd spine-runtimes/spine-sdl ./build.sh ./build/debug/spine-sdl-c-example # Run C example ./build/debug/spine-sdl-cpp-example # Run C++ example
macOS
- Install Xcode
- Install Homebrew
- Install dependencies:
brew install cmake ninja - Clone the repository:
git clone https://github.com/esotericsoftware/spine-runtimes - Build and run:
cd spine-runtimes/spine-sdl ./build.sh ./build/debug/spine-sdl-c-example # Run C example ./build/debug/spine-sdl-cpp-example # Run C++ example