Skip to content

Instantly share code, notes, and snippets.

package main
import "jo:app"
import "core:mem"
import "core:os"
import "core:strings"
import "core:text/edit"
import stbtt "vendor:stb/truetype"
Glyph :: struct {
@dbrookman
dbrookman / build-mpv_silicon.sh
Last active May 1, 2024 17:37
How to build mpv & mpv.app on an Apple silicon Mac
#!/usr/bin/env bash
# Builds mpv & mpv.app on Apple silicon Macs.
# Run this script from the root directory of the mpv repo.
# if anything fails, gtfo
set -ex
meson setup build
meson compile -C build
@d7samurai
d7samurai / .readme.md
Last active March 27, 2024 17:50
Minimal D3D11 pt2

Minimal D3D11 pt2

Follow-up to Minimal D3D11, adding instanced rendering. As before: An uncluttered Direct3D 11 setup & basic rendering primer / API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft.

The main difference here is that the hollow cube is rendered using DrawIndexedInstanced (which saves a lot of vertices compared to the original, so model data is now small enough to be included in the source without being too much in the way), but also all trigonometry and matrix math is moved to the vertex shader, further simplifying the main code.

Each instance is merely this piece of geometry, consisting of 4 triangles:

instanced1

..which is th

@kepano
kepano / obsidian-web-clipper.js
Last active May 5, 2024 16:05
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@mmozeiko
mmozeiko / shader.hlsl
Last active February 4, 2024 17:53
compute shader for rendering monospaced glyphs in grid
//
struct TerminalCell
{
// cell index into GlyphTexture, should be two 16-bit (x,y) values packed: "x | (y << 16)"
uint GlyphIndex;
// 0xAABBGGRR encoded colors, nonzero alpha for Foreground indicates to render colored-glyph
// which means use RGB values from GlyphTexture directly as output, not as ClearType blending weights
uint Foreground;
@mmozeiko
mmozeiko / meow_hash_armv8.h
Last active December 22, 2023 17:02
Meow v0.5 in C and ARMv8
#pragma once
#define MEOW_HASH_VERSION 5
#define MEOW_HASH_VERSION_NAME "0.5/calico"
// Meow hash v0.5 with ARMv8 Crypto Extension instructions
// Ported from https://github.com/cmuratori/meow_hash
// Performance on Pine A64 (Cortex-A53, 1.2GHz)
// (compiled with clang v10.0 with -O3 -mcpu=cortex-a53)
@mmozeiko
mmozeiko / meow_hash_c.h
Created June 29, 2020 00:19
Meow v0.5 in C
#pragma once
#define MEOW_HASH_VERSION 5
#define MEOW_HASH_VERSION_NAME "0.5/calico"
// Meow hash v0.5 in C without dependency on special CPU instructions
// Ported from https://github.com/cmuratori/meow_hash
// Performance on Ryzen 9 3950X
// AESNI code = ~16 bytes/cycle
@machinamentum
machinamentum / microsoft_craziness.h
Created May 19, 2019 05:51
Code for finding the path to Visual Studio by Jon Blow.
//
// Author: Jonathan Blow
// Version: 2
// Date: 7 May, 2019 (update to original version released on 31 August, 2018).
//
// This code is released under the MIT license, which you can find at
//
// https://opensource.org/licenses/MIT
//
//
@d7samurai
d7samurai / .readme.md
Last active April 11, 2024 09:53
Minimal D3D11

Minimal D3D11

Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube

hollowcube

Also check out Minimal D3D11 pt2, reconfigured for instanced rendering and with a smaller, tighter, simplified overall code structure, or Minimal D3D11 pt3, with shadowmapping + showcasing a range of alternative setup and rendering techniques.

@DanielVF
DanielVF / atc.nim
Last active January 28, 2020 01:07
Nim engine, no documentation
import sets
import engine
import strutils
import math
# import log
type
Atc* = ref object of RootObj
available*: HashSet[Ship]
occupied*: seq[bool]