Skip to content

Ecialo/sdl3-hs

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

112 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SDL3 Haskell Bindings Ξ»

Work in progress bindings for the SDL3 library written in Haskell.

Please report any bugs or suggestions you have for the bindings!

Setup Instructions

::: {.note} NOTE: These bindings are for SDL version 3.4.0 as of right now. :::

Cloning the Repository

This repository uses a git submodule for SDL3 headers. Clone with:

git clone --recurse-submodules https://github.com/klukaszek/sdl3-hs.git

Or if you've already cloned without submodules:

git submodule update --init

Installing SDL3

Install SDL3 from source: SDL GitHub

Tip: If you cloned with --recurse-submodules, the SDL3/ directory in this repository is your SDL3 source.

Unix-like

To build SDL3 from source on Unix-like systems (Linux, macOS, BSD):

# Navigate to SDL3 source directory
cd SDL3/

# Create and enter build directory
mkdir build
cd build

# Configure with cmake.
# CMAKE_BUILD_TYPE can be whatever you need it to be.
cmake -DCMAKE_BUILD_TYPE=Release -GNinja ..

# Build
cmake --build . --config Release --parallel

# Install (requires sudo)
sudo cmake --install . --config Release

This will install SDL3 to your system so that cabal can find and build the sdl3 package.

Find your way back to this project's directory and run cabal build sdl3 to build just the package.

Windows

Recommendation: Use the Developer PowerShell or Developer Command Prompt that comes with Visual Studio for best results.

# Navigate to SDL3 source directory
cd SDL3/

# Create and enter build directory
mkdir build
cd build

# Configure with cmake.
# CMAKE_BUILD_TYPE can be whatever you need it to be.
cmake -DCMAKE_BUILD_TYPE=Release -GNinja ..

# Build
cmake --build . --config Release --parallel

# Install (requires sudo)
cmake --install . --config Release

Make sure SDL3 compiles a .DLL file, and pkgconfig knows that SDL3 exists. (You might have to install pkgconfig using your pacman of choice.)

You can do this by setting:

set PKG_CONFIG_PATH="path\to\SDL3\lib\pkgconfig"
# or
$env:PKG_CONFIG_PATH="path\to\SDL3\lib\pkgconfig\"

Ensure the .DLL file is present in your PATH environment variable or within the root directory for this project.

You'll also want to add a cabal.project.local file to the root directory with:

package *
  extra-include-dirs: "path/to/SDL3/include/"
  extra-lib-dirs: "path/to/SDL3/lib/"

Once all of this is done, you can find your way into this directory and run cabal build sdl3 to build just the package.

Building and Running Examples

To build all examples:

cabal build --flag examples

To see a list of all available examples:

cabal run --flag examples

To run a specific example:

cabal run --flag examples EXAMPLE_NAME

For example, to run the init example:

cabal run --flag examples init

You can also build specific executables in a similar manner by specifying the target name.

Build Options

The bindings support two main build configurations:

Dynamic Linking (Default)

cabal build sdl3                    # Build library only
cabal build --flag examples        # Build with examples

This is the default and recommended approach for development. Your executable will depend on SDL3 shared libraries.

Static Linking

cabal build --flag static-linking  # Build with static SDL3 (Linux only)

Creates self-contained executables with SDL3 compiled in. Requires SDL3 to be built with static libraries enabled.

⚠️ macOS Limitation: Static linking is not supported on macOS due to Apple's linking restrictions. The static-linking flag is ignored on macOS. Use dynamic linking with bundled libraries instead (see DISTRIBUTION.md).

Note: Static linking requires SDL3 built with -DBUILD_SHARED_LIBS=OFF. See DISTRIBUTION.md for details.

Cabal Project Configuration

Add to cabal.project.local:

package sdl3
  flags: +static-linking  # Enable static linking

Distribution

For distributing applications to end users, see our comprehensive Distribution Guide which covers:

  • Bundling official SDL3 releases (recommended)
  • Static linking strategies
  • Platform-specific distribution
  • Testing and optimization
  • Production considerations

Quick Summary:

  • Development: Use dynamic linking (default)
  • Distribution: Bundle SDL3 libraries with your executable
  • Self-contained: Use static linking for single-file distribution (Linux only)
  • macOS: Use dynamic linking with bundled libraries

Working Examples

Core Functionality

Initialization & System

  • Init - Basic SDL initialization
  • System - System information and capabilities
  • Platform - Platform-specific functionality
  • CPU Info - Processor information
  • Power - Power state monitoring
  • Hints - SDL configuration hints

Window & Rendering

Rendering

  • Render - 2D rendering basics

Misc

  • Rect - Rectangle basics (no rendering here)

GPU & Graphics

These examples are based off of the original SDL3 GPU Examples

Input & Interaction

User Input

  • Events - Event handling
  • Gamepad - Controller input
  • Touch Device - Touch input handling (Can't test properly but compiles.)
  • Haptic - Force feedback (Can't test properly but compiles.)

User Interface

Audio & Media

Audio

  • Audio - Audio playback
  • WAV - WAV file handling

Camera

  • Camera - Camera device access (tested on macOS)

System Integration

File & Data

  • Filesystem - File system operations
  • Storage - Persistent storage
  • GUID - Globally unique identifier handling

Internationalization

  • Locale - Localization support

Time & Process Management

Time

  • Time - Time functions
  • Timer - Timer functionality

Process

Sensors

Hardware

  • Sensor - Hardware sensor access (Can't test properly but compiles.)

πŸ“Š Binding Status

Last updated: 2025-12-20 03:29 UTC

Summary

  • Total Modules: 55
  • Modules with Bindings: 55
  • Complete Bindings: 55
  • Missing Functions: 0
  • Completion Rate: 100%

Status by Module

Module Status
SDL_assert βœ… Complete
SDL_asyncio βœ… Complete
SDL_atomic βœ… Complete
SDL_audio βœ… Complete
SDL_bits βœ… Complete
SDL_blendmode βœ… Complete
SDL_camera βœ… Complete
SDL_clipboard βœ… Complete
SDL_cpuinfo βœ… Complete
SDL_dialog βœ… Complete
SDL_endian βœ… Complete
SDL_error βœ… Complete
SDL_events βœ… Complete
SDL_filesystem βœ… Complete
SDL_gamepad βœ… Complete
SDL_gpu βœ… Complete
SDL_guid βœ… Complete
SDL_haptic βœ… Complete
SDL_hidapi βœ… Complete
SDL_hints βœ… Complete
SDL_init βœ… Complete
SDL_iostream βœ… Complete
SDL_joystick βœ… Complete
SDL_keyboard βœ… Complete
SDL_keycode βœ… Complete
SDL_loadso βœ… Complete
SDL_locale βœ… Complete
SDL_log βœ… Complete
SDL_messagebox βœ… Complete
SDL_metal βœ… Complete
SDL_misc βœ… Complete
SDL_mouse βœ… Complete
SDL_mutex βœ… Complete
SDL_pen βœ… Complete
SDL_pixels βœ… Complete
SDL_platform βœ… Complete
SDL_power βœ… Complete
SDL_process βœ… Complete
SDL_properties βœ… Complete
SDL_rect βœ… Complete
SDL_render βœ… Complete
SDL_scancode βœ… Complete
SDL_sensor βœ… Complete
SDL_stdinc βœ… Complete
SDL_storage βœ… Complete
SDL_surface βœ… Complete
SDL_system βœ… Complete
SDL_thread βœ… Complete
SDL_time βœ… Complete
SDL_timer βœ… Complete
SDL_touch βœ… Complete
SDL_tray βœ… Complete
SDL_version βœ… Complete
SDL_video βœ… Complete
SDL_vulkan βœ… Complete

Legend

  • βœ… Complete: All functions from the header are bound
  • ⚠️ X missing: Header has bindings but X functions are missing
  • ❌ No bindings: No Haskell bindings exist for this header
  • ❓ Unknown: Status could not be determined

Notes

  • Status reflects core SDL3 headers (test/internal headers excluded)
  • Missing function details are available in the broken/ directory after running the binding checker
  • Some modules may intentionally have no bindings if not applicable to Haskell

About

Haskell bindings for the SDL3 library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Haskell 78.0%
  • C++ 21.7%
  • C 0.3%