Skip to content

Instantly share code, notes, and snippets.

@floooh
floooh / sokol_audio.ast.json
Created August 14, 2020 10:17
clang ast-dump => simplified JSON => Zig
{
"id": "0x7f8a1780fe08",
"kind": "TranslationUnitDecl",
"loc": {},
"range": {
"begin": {},
"end": {}
},
"inner": [
{
@floooh
floooh / sokol_gfx_optionbag.zig
Created August 7, 2020 20:45
sokol-gfx comptime option-bag initialization with Zig
const std = @import("std");
const warn = std.debug.warn;
const sg = @import("sokol_gfx.zig");
pub fn main() void {
var pass_action = make_pass_action(.{
.colors = .{
.{ .action = .CLEAR, .val = .{ 1.0, 0.0, 0.0, 1.0 } },
.{ .action = .CLEAR, .val = .{ 0.0, 1.0, 0.0, 1.0 } },
.{ .action = .DONTCARE }
@floooh
floooh / sokol_gfx.json
Created August 4, 2020 15:58
sokol_gfx.h public API JSON description generated from clang ast-dump
{
"module": "sokol_gfx",
"prefix": "sg_",
"decls": [
{
"kind": "struct",
"name": "sg_buffer",
"fields": [
{
"name": "id",
@floooh
floooh / sokol_gfx_api.txt
Created August 3, 2020 15:50
sokol_gfx.h API description extracted from clang ast-dump
STRUCT sg_buffer:
uint32_t id
TYPEDEF sg_buffer = struct sg_buffer
STRUCT sg_image:
uint32_t id
TYPEDEF sg_image = struct sg_image
@floooh
floooh / imgui-emsc.cc
Created May 29, 2020 17:12
sokol-gfx with C++20 designated init :/
// dynamic vertex- and index-buffers for imgui-generated geometry
bind.vertex_buffers[0] = sg_make_buffer({
.size = MaxVertices * sizeof(ImDrawVert),
.usage = SG_USAGE_STREAM
});
bind.index_buffer = sg_make_buffer({
.size = MaxIndices * sizeof(ImDrawIdx),
.type = SG_BUFFERTYPE_INDEXBUFFER,
.usage = SG_USAGE_STREAM
});
@floooh
floooh / CMakeLists.txt
Created March 26, 2020 17:15
NextSim target structure proposal
if (FIPS_EMSCRIPTEN)
add_definitions(-DSOKOL_GLES2)
set(slang "glsl100")
elseif (FIPS_WINDOWS)
add_definitions(-DSOKOL_D3D11)
set(slang "hlsl5")
elseif (FIPS_OSX)
add_definitions(-DSOKOL_METAL)
if (FIPS_IOS)
set(slang "metal_ios:metal_sim")
@floooh
floooh / c64.sh
Created November 21, 2019 14:10
encode C64 PRG file in URL and open in browser
#!/bin/sh
#
# usage on Mac (assuming 'chmod u+x c64.sh'):
#
# ./c64.sh [PRG filename]
#
open $(base64 $1 | php -r "echo 'https://floooh.github.com/tiny8bit/c64.html?prg='.urlencode(fgets(STDIN));")