57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using Dashboard.Windowing;
|
|
using OpenTK.Graphics;
|
|
using OpenTK.Platform;
|
|
using AppContext = Dashboard.Pal.AppContext;
|
|
using TK = OpenTK.Platform.Toolkit;
|
|
|
|
namespace Dashboard.OpenTK.PAL2
|
|
{
|
|
public class Pal2AppContext : AppContext
|
|
{
|
|
public override string DriverName => "Dashboard OpenTK PAL2.0 Driver";
|
|
public override string DriverVendor => "Dashboard";
|
|
public override Version DriverVersion => new Version(0, 1);
|
|
public GraphicsApiHints GraphicsApiHints { get; set; } = new OpenGLGraphicsApiHints();
|
|
public bool OpenGLBindingsInitialized { get; private set; } = false;
|
|
|
|
private readonly List<PhysicalWindow> _windows = new List<PhysicalWindow>();
|
|
|
|
public override IPhysicalWindow CreatePhysicalWindow()
|
|
{
|
|
PhysicalWindow window = new PhysicalWindow(GraphicsApiHints);
|
|
_windows.Add(window);
|
|
|
|
if (!OpenGLBindingsInitialized)
|
|
{
|
|
OpenGLBindingsInitialized = true;
|
|
GLLoader.LoadBindings(
|
|
new Pal2BindingsContext(TK.OpenGL,
|
|
((OpenGLDeviceContext)window.DeviceContext).ContextHandle));
|
|
}
|
|
|
|
return window;
|
|
}
|
|
|
|
public override IWindow CreateWindow()
|
|
{
|
|
return CreatePhysicalWindow();
|
|
}
|
|
|
|
public override void RunEvents(bool wait)
|
|
{
|
|
TK.Window.ProcessEvents(wait);
|
|
|
|
for (int i = 0; i < _windows.Count; i++)
|
|
{
|
|
if (_windows[i].IsDisposed)
|
|
{
|
|
_windows.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
_windows[i].Paint();
|
|
}
|
|
}
|
|
}
|
|
}
|