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
- 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
- GPU Triangle - Raw triangle rendering
- GPU Clear - Basic screen clearing
- GPU Vertex
Buffer - Vertex buffer usage (matches
gpu-vbuf
) - GPU Textured Quad - Texture mapping
- GPU Custom Sampling - Implementing custom texture sampling logic
- GPU Animated Quad - Animation basics
- GPU Instanced - Instanced rendering
- GPU Stencil - Stencil buffer operations
- GPU Cull - Culling techniques
- GPU Multi-Window - Multiple window rendering
- GPU Draw Indirect - Leveraging indirect draw commands for GPU-driven rendering
- GPU Basic Compute - Basic compute shader usage
- GPU Clear 3D Slice - Clearing a slice of a 3D texture
- GPU Compute Uniforms - Using uniforms with compute shaders
- GPU Compute Sampler - Using samplers within compute shaders
- GPU Compute Tonemapping - Using compute pipelines for HDRI texture tonemapping.
- GPU Copy Consistency - Copy a texture to the GPU, alter it, and draw it to the framebuffer.
- GPU Copy & Readback - Write texture to GPU and read it back, verifying data integrity.
- (... More coming ...)
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
- Dialog - Dialog boxes
- Message Box - Simple message dialogs
- Clipboard - Clipboard manipulation
- Tray - System tray integration
Audio & Media
Audio
Camera
- Camera - Camera device access (Can't test properly but compiles.)
System Integration
File & Data
- Filesystem - File system operations
- Storage - Persistent storage
- GUID - Globally unique identifier handling
Internationalization
- Locale - Localization support
Time & Process Management
Time
Process
- Process - Process management
Sensors
Hardware
- Sensor - Hardware sensor access (Can't test properly but compiles.)