sokol-d 0.3.1
D bindings for sokol
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
This package provides sub packages which can be used individually:
sokol-d:init-exec - A minimal sokol-d application.
Auto-generated D bindings for the sokol headers.
Targets
By default, the backend 3D API will be selected based on the target platform:
- macOS: Metal
- Windows: D3D11
- Linux: GL/Wayland
- Wasm (LDC2 required) - WebGL3/WebGPU support
Usage - template project
dub init -t sokol-d <project-name>
Build Requirements
- D Compiler (DMD/LDC2/GDC) v2.111.0 or higher
- C/C++ compiler (GCC/Clang/MSVC)
- Linux dependencies: libglu1-mesa-dev, mesa-common-dev, xorg-dev, libasound-dev (for X11/Wayland, GL and ALSA development)
Building Native Examples
- First, build the sokol static library:
dub build -c sokol-static
- Then build and run any example:
cd examples
dub :triangle -c native
dub :cube -c native
dub :imgui -c native
Building WebAssembly Examples
- First, build sokol for WebAssembly:
# For WebGL2
dub build -c sokol-webgl
# For WebGPU
dub build -c sokol-wgpu
- Then build any example for WASM:
cd examples
dub :triangle -c wasm # for WebGL2
# or
dub :triangle -c wgpu # for WebGPU
All Configurations
dub build --print-configs
Available configurations:
sokol-static [default] # Static library build
sokol-shared # Shared/dynamic library build
sokol-wayland-static # Wayland static build for Linux
sokol-wayland-shared # Wayland shared build for Linux
imgui-static # Sokol + Dear ImGui static build
imgui-shared # Sokol + Dear ImGui shared build
imgui-wgles3 # Sokol + Dear ImGui WebGL ES3 build
imgui-wgpu # Sokol + Dear ImGui WebGPU build
sokol-wgles3 # WebGL ES3 build
sokol-wgpu # WebGPU build
genshaders # [re]Generate shader code
Additional Build Options
Library Types
- Static library:
dub build -c sokol-static
- Shared library:
dub build -c sokol-shared
Linux Display Server
- X11 (default with static):
dub build -c sokol-static
- Wayland static:
dub build -c sokol-wayland-static
- Wayland shared:
dub build -c sokol-wayland-shared
Build Modes
Available for all configurations:
- Debug:
-b debug
- Release:
-b release
- Release (no bounds checking):
-b release-nobounds
- Release (better C):
-b release-betterc
Available Examples
- blend
- bufferoffsets
- clear
- cube
- debugtext
- droptest
- imgui
- instancing
- instancingcompute
- saudio
- sglcontext
- sglpoints
- triangle
See examples
Shaders
Checkout sokol-tools for a sokol shader pipeline! It supports these D bindings and all shaders in the examples folder
here have been compiled using it with -f sokol_d
!
dub -c genshaders
License and attributions
This code is released under the zlib license (see LICENSE for info). Parts of gen_d.py
have been copied and modified from
the zig-bindings[^1] and rust-bindings[^2] for sokol.
The sokol headers are created by Andre Weissflog (floooh) and sokol is released under its own license[^3].
- 0.3.1 released 25 days ago
- kassane/sokol-d
- Zlib
- Authors:
- Sub packages:
- sokol-d:init-exec
- Dependencies:
- none
- Versions:
-
0.3.5 2025-Jun-29 0.3.4 2025-Jun-15 0.3.3 2025-Jun-08 0.3.2 2025-Jun-06 0.3.1 2025-Jun-06 - Download Stats:
-
-
2 downloads today
-
8 downloads this week
-
23 downloads this month
-
63 downloads total
-
- Score:
- 1.9
- Short URL:
- sokol-d.dub.pm