HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
floooh
sokol-samples
C2019–2026
floooh / sokol-samples

sokol-samples

Sample code for https://github.com/floooh/sokol

3Distinct people
19Mentions
0Explicit recommenders
810GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Sample code for https://github.com/floooh/sokol

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year19 dated mentions

Observed mentions: 2019-03-07 14:25:33 UTC to 2026-09-30 15:56:14 UTC.

02462019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 7 mentions; 0 submissions, 7 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC101
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC202
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC303
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC303
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC707

What Hacker News says

19 sources
Slug doesn't use "bitmap" font data but more like parameter lookup tables in storage buffers, pre-processed from TTF files. The lookup data can of course also live in textures (so that it works in WebGL), but using those textures as "poor-man's storage buffers", e.g. fetching the data directly without filtering. The pixel shader is indeed quite complex compared to SDF: https://github.com/floooh/sokol-samples/blob/8afa83928ce1870...
In SDF vs. MSDF vs. Slug: GPU Text Rendering
Here's a simple Slug rendering example on top of sokol_gfx.h: via WebGPU backend: https://floooh.github.io/sokol-webgpu/slug-sapp.html via WebGL2 backend: https://floooh.github.io/sokol-html5/slug-sapp.html There's quite a bit of helper code plus stb_truetype.h and stb_ds.h under the hood to parse TTF files and crunch the TTF curve data into the runtime format expected by the Slug shader (this stuff should better go into an offline asset pipeline tool): https://github.com/floooh/sokol-samples/blob/master/libs/slu... ...the actual text rendering code is also taking a couple of shortcuts, e.g. no kerning, no right-to-left, and also no text shaping. There's also a new and complete text rendering stack by Mikko Mononen called Skribidi (AFAIK not based on Slug though): https://github.com/memononen/Skribidi ...the list of external dependencies
Read the rest
is a bit scary for a small self-contained sample though (Harfbuzz, SheenBidi, libunibreak, etc...), but that basically shows that proper international text rendering is really damn hard, even when trying to simplify the code as much as possible.
In SDF vs. MSDF vs. Slug: GPU Text Rendering
I wrote a little demo to run microui on top of the sokol headers here, it's really interesting in how minimal it is. WASM demo: https://floooh.github.io/sokol-html5/sgl-microui-sapp.html Source code: https://github.com/floooh/sokol-samples/blob/master/sapp/sgl... The renderer backend is just a bunch of C functions you need to provide: https://github.com/floooh/sokol-samples/blob/3f4185a8578cd2b... It's also interesting to compare the binary sizes: microui sample (https://floooh.github.io/sokol-html5/sgl-microui-sapp.html): 79.6 KBytes compressed download Nuklear sample (https://floooh.github.io/sokol-html5/nuklear-sapp.html): 155 kb compressed download Dear ImGui sample (https://floooh.github.io/sokol-html5/imgui-sapp.html): 491 KB compressed download
In MicroUI – A tiny, portable, immediate-mode UI library written in ANSI C
> ImGui has C++ API as first-class citizen Dear ImGui via the C bindings is actually quite nice and not much less convenient than the C++ API (the only notable difference is that the C API has no overloads and default params). E.g. here's a control panel UI (from the below ozz-animation sample) with the 'Dear Bindings' approach (using a custom 'ig' prefix)): https://github.com/floooh/sokol-samples/blob/d8429d701eb7a8c... Dear ImGui is a bit of an outlier for C++ libraries though, since it is essentially a C API wrapped in a namespace. OzzAnimation is also fairly trivial to wrap in an (abstracted) C API, for instance I use this in some of the sokol-samples: https://github.com/floooh/sokol-samples/blob/master/libs/ozz... Implementation: https://github.com/floooh/sokol-samples/blob/master/libs/ozz... ...used in this sample: https://github.co
Read the rest
m/floooh/sokol-samples/blob/master/sapp/shd... ...WASM live version: https://floooh.github.io/sokol-html5/shdfeatures-sapp.html TL;DR: quite a few C++ libraries out of the game-dev world are actually quite easy to access from C or languages that can talk to C APIs, mainly because the game-dev world typically uses a very 'orthodox' subset of C++ (no or very restricted C++ stdlib usage, no rtti, no exceptions, ideally no smart pointers in the public API).
In Testing the Swift C compatibility with Raylib (+WASM)
Any language feature added in C99 and later. In GCC and Clang it's quite relaxed since their C++ frontends pull in a couple of modern C features as non-standard C++ extensions, but MSVC has a strict separation between the C++ and C frontend and doesn't allow this sort of 'cross-pollution'. As a quick example, this C99 code block has at least 4 features that don't work in C++: https://github.com/floooh/sokol-samples/blob/91bd8c6f9f52149... - taking the address of an adhoc-created struct in a function call - random array access in struct initialization - designator chaining in struct initialization - designators can be out-of-order in C but not C++ ...also using unions as different views on the same memory is actually useful sometimes.
In Why Objective-C
I don't know sorry. For debugging GL I usually switch to Windows with RenderDoc (or some current NVIDIA tool - does Nsight still exist?). RenderDoc on Linux appears to work fine for X11 apps via XWayland btw (just testing here via the sokol-samples with the sokol-gfx GL backend: https://github.com/floooh/sokol-samples, just another reason to not have a native Wayland backend but instead rely on the XWayland shim I guess...
In Ask HN: DDD was a great debugger – what would a modern equivalent look like?
> Zig takes the same attitude as C and C++ of using const to indicate an immutable rather than a constant I think it's a bit more complicated than that: AFAIK Zig consts without explicit type may be comptime_int or comptime_float, and those don't exist at runtime. Only consts with an explicit type annotation are 'runtime consts'. Also see: https://www.godbolt.org/z/esTr463bT ...still, I think Rust should allow to infer the type at least inside struct initialization, it would make designated init code like this a lot less noisy (Zig would suffer from the same problem if it hadn't the .{} syntax): https://github.com/floooh/sokol-rust/blob/main/examples/texc... ...C99 is still the 'benchmark' when it comes to struct initialization: https://github.com/floooh/sokol-samples/blob/29d5e9f4a56ae18...
In Zig's Lovely Syntax
When initializing a struct, Zig currently doesn't allow chained designators and also doesn't allow to partially initialize arrays and have the rest of the array filled up with default values (the first one isn't all that important, but the second is). E.g. the closest Zig equivalent to this C99 code: https://github.com/floooh/sokol-samples/blob/b3bc55c4411fa03... ...is this: https://github.com/floooh/sokol-zig/blob/a4b3c287fadd153a504... ...note how part of the initialization had to be moved out into separate assignments, which means the struct can't be created as const. There's a ticket about this here, but it's currently not high-priority: https://github.com/ziglang/zig/issues/6068 Zig also isn't alone in this, I haven't encountered any other programming language yet which has such a flexible struct initialization syntax as C99. Odin is
Read the rest
In Zig cookbook: collection of simple Zig programs that demonstrate good practices
This is a simple Pong-like I've written in Raylib compiled to WASM - https://wasm-stuff.netlify.app/pong Source code is here: https://github.com/rrampage/skitter/tree/master/pong-raylib It is fairly straightforward to get Raylib running in the browser. I used @flohofwoe's HTML shell file ( https://github.com/floooh/sokol-samples/blob/master/webpage/... ). Compilation is something like: emcc -o target/pong.html -Wall -Wextra -std=c99 pong-raylib/pong.c lib/libraylibweb.a -I ./include -sUSE_GLFW=3 -sSINGLE_FILE -Oz --closure 1 -sFILESYSTEM=0 --shell-file pong-raylib/shell.html
In Building a Web Game in C
PS: also if shader functions could be directly defined as 'regular functions' in CPU-side source code (and behind a special function pointer type), there would be no need for string literal shenanigans like this: https://github.com/floooh/sokol-samples/blob/3f10c1a0620cec9... (and shader compilation would happen during the regular build and would also generate regular compiler errors - with current toolchains that's only possible with a lot of build system magic)
In Learn WebGPU
I think something along those lines (rarely used...) was also given by the C++ Committee as justification why so much of the C99 designated init feature set was left out of C++20, which is a bit of a shame. All C99 designated-init 'sub-features' complement each other nicely once you start using them. It's a great way for building 'data-centric' APIs. For instance check out this call to create a 3D-API pipeline-state-object in C99: https://github.com/floooh/sokol-samples/blob/ad9047e228a8441...
In Next C compiler is a D compiler: Introducing DMD's ImportC
It's an STB-style single-file library, which means the implementation is in a separate ifdef-block from the interface declarations, this allows to compile the implementation in a different source file (which can be a C file) from the source files which use the library (which can be C++ files). Here's for example such an "implementation source file" example (using stb_image.h): https://github.com/floooh/sokol-samples/blob/master/libs/stb... ...or for a whole collection of related single-file libraries: https://github.com/floooh/sokol-samples/blob/master/libs/sok...
In Nuklear: A cross-platform GUI library in C

Showing the 15 most recent of 19 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.