Skip to content

Instantly share code, notes, and snippets.

@Reedbeta
Reedbeta / gamuts.svg
Created December 19, 2020 19:44
Common RGB gamuts on CIE chromaticity diagram
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#pragma once
// String tokenizing iterator
// by Nathan Reed, 2020-08-06. Licensed CC0 https://creativecommons.org/publicdomain/zero/1.0/
//
// Use it like:
//
// for (auto token : IterTokens(" Bird \t\tFish Dog Cat "))
// {
// // token is a std::string_view pointing into the original string
@dwilliamson
dwilliamson / uptr.h
Last active April 26, 2020 08:36
Scoped (unique) "smart" pointer, deleting the pointer on destruction. Doesn't wrap the unique pointer in accessor functions, instead requiring explicit dereferencing and a const pointer that can't (shouldn't) be modified externally.
template <typename Type>
struct uptr
{
uptr() = default;
uptr(Type* ptr)
: ptr(ptr)
{
}
@JarkkoPFC
JarkkoPFC / sphere_screen_extents.h
Last active June 13, 2023 21:27
Calculates view space 3D sphere extents on the screen
struct vec3f {float x, y, z;};
struct vec4f {float x, y, z, w;};
struct mat44f {vec4f x, y, z, w;};
//============================================================================
// sphere_screen_extents
//============================================================================
// Calculates the exact screen extents xyzw=[left, bottom, right, top] in
// normalized screen coordinates [-1, 1] for a sphere in view space. For
// performance, the projection matrix (v2p) is assumed to be setup so that
#include "FunctionalPropertyModifiers.h"
void fpmCallStore::CallAll(double time)
{
for (auto i : m_FunctionCallMap)
{
const fpmFunctionCalls& calls = i->value;
calls.call_all_fn(i->key, calls, time);
struct NumberParser {
enum {
NPF_Sign = (1 << 0),
NPF_Negative = (1 << 1),
NPF_Base = (1 << 2),
NPF_Dot = (1 << 3),
NPF_Exponent = (1 << 4),
NPF_ExponentSign = (1 << 5),
NPF_ExponentNegative = (1 << 6),
NPF_Inf = (1 << 7),
@Reedbeta
Reedbeta / interesting-libs.txt
Last active July 4, 2023 02:38
Interesting libraries I might like to use in a project
Interesting libraries I might like to use in a project...
Asset loading:
assetsys.h - virtual filesystem with ZIP backing, overlaying, etc https://github.com/mattiasgustavsson/libs/blob/master/docs/assetsys.md
cute_filewatch.h - file modification watching, for runtime reloading etc https://github.com/RandyGaul/cute_headers/blob/master/cute_filewatch.h
flatbuffers - data serialization, zero-copy deserialization, extensible schemas https://github.com/google/flatbuffers
stb_image - https://github.com/nothings/stb/blob/master/stb_image.h
tinyexr - https://github.com/syoyo/tinyexr
tinygltf - https://github.com/syoyo/tinygltf
tinyobjloader - https://github.com/syoyo/tinyobjloader
@sebbbi
sebbbi / SinglePassMipPyramid.hlsl
Last active January 12, 2024 07:16
Single pass globallycoherent mip pyramid generation
// NOTE: Must bind 8x single mip RWTexture views, because HLSL doesn't have .mips member for RWTexture2D. (SRVs only have .mips member)
// NOTE: globallycoherent attribute is needed. Without it writes aren't guaranteed to be seen by other groups
globallycoherent RWTexture2D<float> MipTextures[8];
RWTexture2D<uint> Counters[8];
groupshared uint CounterReturnLDS;
[numthreads(16, 16, 1)]
void GenerateMipPyramid(uint3 Tid : SV_DispatchThreadID, uint3 Group : SV_GroupId, uint Gix : SV_GroupIndex)
{
[unroll]
//
// TinyCRT, revamp and TinyWin support by Don Williamson, 2011
// Based on http://www.codeproject.com/KB/library/tlibc.aspx and LIBCTINY by Matt Pietrek
//
#pragma once
#ifdef USE_DEFAULT_CRT