Skip to content

Instantly share code, notes, and snippets.

View dsuoch-intel's full-sized avatar

Dietmar Suoch dsuoch-intel

  • Intel
  • Santa Barbara, CA
View GitHub Profile
#pragma once
// This allows windows.h to be included first, overriding this header file, but be careful
// not to do this everywhere as compile-times suffer.
#ifndef _WINDOWS_
#define _WIN32_WINNT 0x0601 // _WIN32_WINNT_WIN7
@graphitemaster
graphitemaster / WORKING_AROUND_OFFSETOF_LIMITATIONS.MD
Last active February 29, 2024 08:49
Working around offsetof limitations in C++

Working around offsetof limitations in C++:

There is sometimes a situation in which one needs to get the relative offset of a structure field, common examples of this include serialization frameworks which aid to serialize objects, vertex attributes for rendering (D3D, GL.), etc.

The most common technique for getting this information is through the offsetof macro defined in stddef.h. Unfortunately using the macro in C++ comes with a new set of restrictions that prevent some (subjectively valid) uses of it.

@Flafla2
Flafla2 / Perlin_Tiled.cs
Last active February 19, 2024 16:29
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;