37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using OpenTK;
|
|
using OpenTK.Graphics;
|
|
|
|
namespace Dashboard.Drawing.OpenGL
|
|
{
|
|
public class GLEngine
|
|
{
|
|
private readonly Dictionary<IGLContext, ContextExecutor> _executors = new Dictionary<IGLContext, ContextExecutor>();
|
|
|
|
public bool IsInitialized { get; private set; } = false;
|
|
public ContextResourcePoolManager ResourcePoolManager { get; private set; } = new ContextResourcePoolManager();
|
|
|
|
public void Initialize(IBindingsContext? bindingsContext = null)
|
|
{
|
|
if (IsInitialized)
|
|
return;
|
|
IsInitialized = true;
|
|
|
|
if (bindingsContext != null)
|
|
GLLoader.LoadBindings(bindingsContext);
|
|
}
|
|
|
|
public ContextExecutor GetExecutor(IGLContext glContext)
|
|
{
|
|
if (!_executors.TryGetValue(glContext, out ContextExecutor? executor))
|
|
{
|
|
executor = new ContextExecutor(this, glContext);
|
|
executor.Initialize();
|
|
|
|
_executors.Add(glContext, executor);
|
|
}
|
|
|
|
return executor;
|
|
}
|
|
}
|
|
}
|