Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Forever working on Smile

seanofw seanofw

💭
Forever working on Smile
View GitHub Profile
View TimedGameWindow.cs
using System;
using System.Runtime.InteropServices;
using System.Threading;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Desktop;
// Define this if you're running on Microsoft Windows, which supports
// high-precision sleep timers. Enabling this can result in better CPU usage
// and power usage if your program doesn't need the CPU fully in every frame.
#define HIGH_PRECISION_SLEEP
View rand.cs
private static volatile int RandomSeed = 1;
private static int FastRand()
{
retry:
int oldSeed = RandomSeed;
int newSeed = unchecked(oldSeed * 1103515245 + 12345);
if (Interlocked.CompareExchange(ref RandomSeed, newSeed, oldSeed) != oldSeed)
goto retry;