Create a gist now

Instantly share code, notes, and snippets.

The load-time GL call scheduler that FEZ 1.12 uses
using System;
using System.Collections.Concurrent;
namespace FezEngine.Tools
{
public static class DrawActionScheduler
{
static readonly ConcurrentQueue<Action> DeferredDrawActions = new ConcurrentQueue<Action>();
public static void Schedule(Action action)
{
if (!PersistentThreadPool.IsOnMainThread)
DeferredDrawActions.Enqueue(action);
else
action();
}
public static void Process()
{
Action deferredAction;
while (DeferredDrawActions.TryDequeue(out deferredAction))
deferredAction();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment