Skip to content

Instantly share code, notes, and snippets.

View seanofw's full-sized avatar
💭
Forever working on Smile

seanofw seanofw

💭
Forever working on Smile
View GitHub Profile
@seanofw
seanofw / . OpenTK.Mathematics.csproj.diff
Last active November 6, 2023 20:41
Patches to make OpenTK.Mathematics build on .NET Standard 2.0 (and .NET Framework 4.6).
diff --git a/src/OpenTK.Mathematics/OpenTK.Mathematics.csproj b/src/OpenTK.Mathematics/OpenTK.Mathematics.csproj
index b2f0466db..704323b26 100644
--- a/src/OpenTK.Mathematics/OpenTK.Mathematics.csproj
+++ b/src/OpenTK.Mathematics/OpenTK.Mathematics.csproj
@@ -1,13 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFrameworks>netstandard2.1;netcoreapp3.1</TargetFrameworks>
+ <TargetFrameworks>netstandard2.1;netcoreapp3.1;netstandard2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
using System;
using System.Runtime.InteropServices;
public class HighPrecisionSleep : IDisposable
{
private IntPtr _waitableTimerHandle;
public HighPrecisionSleep()
{
_waitableTimerHandle = Win32.CreateWaitableTimer(IntPtr.Zero, true, null);
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
@seanofw
seanofw / rand.cs
Last active February 1, 2021 01:43
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;