Skip to content

Instantly share code, notes, and snippets.

View Guarneri1743's full-sized avatar

Guarneri1743

  • China
View GitHub Profile
@rygorous
rygorous / main.cpp
Created December 24, 2024 15:07
Direct UNORM/SNORM conversion test program
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
static uint32_t float_to_bits(float x)
{
uint32_t u;
memcpy(&u, &x, sizeof(x));
return u;
@htfy96
htfy96 / static_inline_example.md
Last active September 2, 2025 04:43
static inline vs inline vs static in C++

In this article we compared different behavior of static, inline and static inline free functions in compiled binary. All the following test was done under g++ 7.1.1 on Linux amd64, ELF64.

Test sources

header.hpp

#pragma once

inline int only_inline() { return 42; }
static int only_static() { return 42; }
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active November 1, 2025 13:44
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@aprell
aprell / va_nargs.c
Last active September 22, 2025 22:26
Counting arguments in variadic macros
// RUN: cc -Wall -Wextra %s && ./a.out
#include <assert.h>
#if defined(__GNUC__) || defined(__clang__)
// Supports 0-10 arguments
#define VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
// ## deletes preceding comma if _VA_ARGS__ is empty (GCC, Clang)
#define VA_NARGS(...) VA_NARGS_IMPL(_, ## __VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#else