Compare commits
3 Commits
36dbcac8d9
...
d20d929515
| Author | SHA1 | Date | |
|---|---|---|---|
| d20d929515 | |||
| 3b9fa5c9fb | |||
| 027ebe8dbd |
@@ -34,7 +34,25 @@ namespace Dashboard.Events
|
|||||||
|
|
||||||
public enum ScanCode
|
public enum ScanCode
|
||||||
{
|
{
|
||||||
// TODO:
|
// TODO: this array is from ReFuel, see if this makes any sense.
|
||||||
|
|
||||||
|
Esc, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
|
||||||
|
Tilde, _1, _2, _3, _4, _5, _6, _7, _8, _9, _0, Minus, Equals, Backspace,
|
||||||
|
Tab, Q, W, E, R, T, Y, U, I, O, P, LBracket, RBracket, Backslash,
|
||||||
|
CapsLock, A, S, D, F, G, H, J, K, L, Semicolon, Quote, Enter,
|
||||||
|
LShift, Z, X, C, V, B, N, M, Dot, Comma, Slash, RShift,
|
||||||
|
LCtrl, LWin, LAlt, Space, RAlt, RWin, Menu, RCtrl,
|
||||||
|
|
||||||
|
PrtSc, ScrollLock, PauseBreak,
|
||||||
|
Insert, Delete, Home, End, PgUp, PgDown,
|
||||||
|
Up, Down, Left, Right,
|
||||||
|
|
||||||
|
NumLock, NumDiv, NumMul, NumSub, NumAdd, NumEnter, NumDecimal,
|
||||||
|
Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9,
|
||||||
|
|
||||||
|
IsoB00,
|
||||||
|
|
||||||
|
KeysMax,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class KeyboardButtonEventArgs(KeyCode keyCode, ScanCode scanCode, ModifierKeys modifierKeys, bool up)
|
public class KeyboardButtonEventArgs(KeyCode keyCode, ScanCode scanCode, ModifierKeys modifierKeys, bool up)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
using System.Numerics;
|
||||||
using Dashboard.Collections;
|
using Dashboard.Collections;
|
||||||
using Dashboard.Windowing;
|
using Dashboard.Windowing;
|
||||||
using BindingFlags = System.Reflection.BindingFlags;
|
|
||||||
|
|
||||||
namespace Dashboard.Pal
|
namespace Dashboard.Pal
|
||||||
{
|
{
|
||||||
public abstract class DeviceContext : IContextBase<DeviceContext, IDeviceContextExtension>
|
public abstract class DeviceContext : IContextBase<DeviceContext, IDeviceContextExtension>, IDeviceContext
|
||||||
{
|
{
|
||||||
private readonly TypeDictionary<IDeviceContextExtension> _extensions =
|
private readonly TypeDictionary<IDeviceContextExtension> _extensions =
|
||||||
new TypeDictionary<IDeviceContextExtension>(true);
|
new TypeDictionary<IDeviceContextExtension>(true);
|
||||||
@@ -19,6 +19,9 @@ namespace Dashboard.Pal
|
|||||||
public abstract string DriverName { get; }
|
public abstract string DriverName { get; }
|
||||||
public abstract string DriverVendor { get; }
|
public abstract string DriverVendor { get; }
|
||||||
public abstract Version DriverVersion { get; }
|
public abstract Version DriverVersion { get; }
|
||||||
|
public abstract ISwapGroup SwapGroup { get; }
|
||||||
|
public abstract Vector2 FramebufferSize { get; }
|
||||||
|
public virtual bool DoubleBuffered { get; } = false;
|
||||||
|
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDisposed { get; private set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.Numerics;
|
||||||
using Dashboard.Drawing;
|
using Dashboard.Drawing;
|
||||||
using Dashboard.OpenGL.Drawing;
|
using Dashboard.OpenGL.Drawing;
|
||||||
using Dashboard.Pal;
|
using Dashboard.Pal;
|
||||||
@@ -27,6 +28,9 @@ namespace Dashboard.OpenGL
|
|||||||
public override string DriverName => "Dashboard OpenGL Device Context";
|
public override string DriverName => "Dashboard OpenGL Device Context";
|
||||||
public override string DriverVendor => "Dashboard";
|
public override string DriverVendor => "Dashboard";
|
||||||
public override Version DriverVersion => new Version(0, 1, 0);
|
public override Version DriverVersion => new Version(0, 1, 0);
|
||||||
|
public override ISwapGroup SwapGroup { get; }
|
||||||
|
public override Vector2 FramebufferSize => GLContext.FramebufferSize;
|
||||||
|
public override bool DoubleBuffered { get; } = true;
|
||||||
|
|
||||||
public Version GLVersion { get; }
|
public Version GLVersion { get; }
|
||||||
public string GLRenderer { get; }
|
public string GLRenderer { get; }
|
||||||
@@ -39,9 +43,11 @@ namespace Dashboard.OpenGL
|
|||||||
private readonly ConcurrentQueue<Task> _beforeDrawActions = new ConcurrentQueue<Task>();
|
private readonly ConcurrentQueue<Task> _beforeDrawActions = new ConcurrentQueue<Task>();
|
||||||
private readonly ConcurrentQueue<Task> _afterDrawActions = new ConcurrentQueue<Task>();
|
private readonly ConcurrentQueue<Task> _afterDrawActions = new ConcurrentQueue<Task>();
|
||||||
|
|
||||||
public GLDeviceContext(Application app, IWindow? window, IGLContext context) : base(app, window)
|
public GLDeviceContext(Application app, IWindow? window, IGLContext context, ISwapGroup swap) : base(app, window)
|
||||||
{
|
{
|
||||||
GLContext = context;
|
GLContext = context;
|
||||||
|
SwapGroup = swap;
|
||||||
|
|
||||||
context.MakeCurrent();
|
context.MakeCurrent();
|
||||||
GLLoader.LoadBindings(new GLContextBindingsContext(context));
|
GLLoader.LoadBindings(new GLContextBindingsContext(context));
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ namespace Dashboard.OpenGL
|
|||||||
/// <remarks>-1 assigns no group.</remarks>
|
/// <remarks>-1 assigns no group.</remarks>
|
||||||
public int ContextGroup { get; }
|
public int ContextGroup { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The size of the framebuffer in pixels.
|
|
||||||
/// </summary>
|
|
||||||
public Vector2 FramebufferSize { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the context is disposed.
|
/// Called when the context is disposed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -277,6 +277,46 @@ namespace Dashboard.OpenTK.PAL2
|
|||||||
|
|
||||||
private static ScanCode GetScanCode(Scancode scanCode) => scanCode switch
|
private static ScanCode GetScanCode(Scancode scanCode) => scanCode switch
|
||||||
{
|
{
|
||||||
|
// TODO: Revise this array.
|
||||||
|
Scancode.A => ScanCode.A,
|
||||||
|
Scancode.B => ScanCode.B,
|
||||||
|
Scancode.C => ScanCode.C,
|
||||||
|
Scancode.D => ScanCode.D,
|
||||||
|
Scancode.E => ScanCode.E,
|
||||||
|
Scancode.F => ScanCode.F,
|
||||||
|
Scancode.G => ScanCode.G,
|
||||||
|
Scancode.H => ScanCode.H,
|
||||||
|
Scancode.J => ScanCode.J,
|
||||||
|
Scancode.K => ScanCode.K,
|
||||||
|
Scancode.L => ScanCode.L,
|
||||||
|
Scancode.M => ScanCode.M,
|
||||||
|
Scancode.N => ScanCode.N,
|
||||||
|
Scancode.O => ScanCode.O,
|
||||||
|
Scancode.P => ScanCode.P,
|
||||||
|
Scancode.Q => ScanCode.Q,
|
||||||
|
Scancode.R => ScanCode.R,
|
||||||
|
Scancode.S => ScanCode.S,
|
||||||
|
Scancode.T => ScanCode.T,
|
||||||
|
Scancode.U => ScanCode.U,
|
||||||
|
Scancode.V => ScanCode.V,
|
||||||
|
Scancode.W => ScanCode.W,
|
||||||
|
Scancode.X => ScanCode.X,
|
||||||
|
Scancode.Y => ScanCode.Y,
|
||||||
|
Scancode.Z => ScanCode.Z,
|
||||||
|
Scancode.D0 => ScanCode._0,
|
||||||
|
Scancode.D1 => ScanCode._1,
|
||||||
|
Scancode.D2 => ScanCode._2,
|
||||||
|
Scancode.D3 => ScanCode._3,
|
||||||
|
Scancode.D4 => ScanCode._4,
|
||||||
|
Scancode.D5 => ScanCode._5,
|
||||||
|
Scancode.D6 => ScanCode._6,
|
||||||
|
Scancode.D7 => ScanCode._7,
|
||||||
|
Scancode.D8 => ScanCode._8,
|
||||||
|
Scancode.D9 => ScanCode._9,
|
||||||
|
Scancode.UpArrow => ScanCode.Up,
|
||||||
|
Scancode.DownArrow => ScanCode.Down,
|
||||||
|
Scancode.LeftArrow => ScanCode.Left,
|
||||||
|
Scancode.RightArrow => ScanCode.Right,
|
||||||
_ => (ScanCode)0,
|
_ => (ScanCode)0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace Dashboard.OpenTK.PAL2
|
|||||||
{
|
{
|
||||||
Application = app;
|
Application = app;
|
||||||
WindowHandle = window;
|
WindowHandle = window;
|
||||||
DeviceContext = new GLDeviceContext(app, this, new Pal2GLContext(window, context));
|
DeviceContext = new GLDeviceContext(app, this, new Pal2GLContext(window, context), new DummySwapGroup(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhysicalWindow(Application app, GraphicsApiHints hints)
|
public PhysicalWindow(Application app, GraphicsApiHints hints)
|
||||||
@@ -81,7 +81,8 @@ namespace Dashboard.OpenTK.PAL2
|
|||||||
{
|
{
|
||||||
case GraphicsApi.OpenGL:
|
case GraphicsApi.OpenGL:
|
||||||
case GraphicsApi.OpenGLES:
|
case GraphicsApi.OpenGLES:
|
||||||
return new GLDeviceContext(app, window, new Pal2GLContext(handle, TK.OpenGL.CreateFromWindow(handle)));
|
OpenGLContextHandle context = TK.OpenGL.CreateFromWindow(handle);
|
||||||
|
return new GLDeviceContext(app, window, new Pal2GLContext(handle, context), new DummySwapGroup(context));
|
||||||
default:
|
default:
|
||||||
throw new Exception($"Unknown graphics API {hints.Api}.");
|
throw new Exception($"Unknown graphics API {hints.Api}.");
|
||||||
}
|
}
|
||||||
@@ -146,5 +147,28 @@ namespace Dashboard.OpenTK.PAL2
|
|||||||
return Math.Max(x, y);
|
return Math.Max(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DummySwapGroup(OpenGLContextHandle context) : ISwapGroup
|
||||||
|
{
|
||||||
|
public int SwapInterval
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
TK.OpenGL.SetCurrentContext(context);
|
||||||
|
return TK.OpenGL.GetSwapInterval();
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
TK.OpenGL.SetCurrentContext(context);
|
||||||
|
TK.OpenGL.SetSwapInterval(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Swap()
|
||||||
|
{
|
||||||
|
TK.OpenGL.SwapBuffers(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ namespace Dashboard.Controls
|
|||||||
foreach (Control child in this)
|
foreach (Control child in this)
|
||||||
child.SendEvent(this, new PaintEventArgs(dc));
|
child.SendEvent(this, new PaintEventArgs(dc));
|
||||||
|
|
||||||
|
base.OnPaint(dc);
|
||||||
|
|
||||||
dc.End();
|
dc.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user