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: These bindings are for SDL version 3.3 as of right now.

Install SDL3 from source: SDL GitHub

Linux

To build SDL3 from source on Linux:

# Navigate to SDL3 source directory
cd path/to/SDL3/source

# 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 to build the package with examples, or 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 path/to/SDL3/source

# 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. If you would like to install the examples, run cabal build instead.

SDL.h Header File Support Checklist

🟧 means that the related header file should be implemented for the most part. Some things might be missing or non-functioning, though I have tried to be careful.

Header File Status Notes
SDL3/SDL_stdinc.h 🟧
SDL3/SDL_assert.h 🟧
SDL3/SDL_asyncio.h 🟧
SDL3/SDL_atomic.h 🟧
SDL3/SDL_audio.h 🟧
SDL3/SDL_bits.h 🟧
SDL3/SDL_blendmode.h 🟧
SDL3/SDL_camera.h 🟧
SDL3/SDL_clipboard.h 🟧
SDL3/SDL_cpuinfo.h 🟧
SDL3/SDL_dialog.h 🟧
SDL3/SDL_endian.h 🟧
SDL3/SDL_error.h 🟧
SDL3/SDL_events.h 🟧
SDL3/SDL_filesystem.h 🟧
SDL3/SDL_gamepad.h 🟧
SDL3/SDL_gpu.h 🟧
SDL3/SDL_guid.h 🟧
SDL3/SDL_haptic.h 🟧
SDL3/SDL_hidapi.h 🟧
SDL3/SDL_hints.h 🟧
SDL3/SDL_init.h 🟧
SDL3/SDL_iostream.h 🟧
SDL3/SDL_joystick.h 🟧
SDL3/SDL_keyboard.h 🟧
SDL3/SDL_keycode.h 🟧
SDL3/SDL_loadso.h 🟧
SDL3/SDL_locale.h 🟧
SDL3/SDL_log.h 🟧
SDL3/SDL_messagebox.h 🟧
SDL3/SDL_metal.h 🟧
SDL3/SDL_misc.h 🟧
SDL3/SDL_mouse.h 🟧
SDL3/SDL_mutex.h 🟧
SDL3/SDL_pen.h 🟧
SDL3/SDL_pixels.h 🟧
SDL3/SDL_platform.h 🟧
SDL3/SDL_power.h 🟧
SDL3/SDL_process.h 🟧
SDL3/SDL_properties.h 🟧
SDL3/SDL_rect.h 🟧
SDL3/SDL_render.h 🟧
SDL3/SDL_scancode.h 🟧
SDL3/SDL_sensor.h 🟧
SDL3/SDL_storage.h 🟧
SDL3/SDL_surface.h 🟧
SDL3/SDL_system.h 🟧
SDL3/SDL_thread.h 🟧
SDL3/SDL_time.h 🟧
SDL3/SDL_timer.h 🟧
SDL3/SDL_tray.h 🟧
SDL3/SDL_touch.h 🟧
SDL3/SDL_version.h 🟧
SDL3/SDL_video.h 🟧

Working Examples

Core Functionality

Initialization & System

Window & Rendering

Rendering

Misc

GPU & Graphics

These examples are based off of the original SDL3 GPU Examples

Input & Interaction

User Input

User Interface

Audio & Media

Audio

Camera

System Integration

File & Data

Internationalization

Time & Process Management

Time

Process

Sensors

Hardware