106 lines
3.1 KiB
C#
106 lines
3.1 KiB
C#
using BlurgText;
|
|
using Dashboard.BlurgText;
|
|
using Dashboard.BlurgText.OpenGL;
|
|
using Dashboard.Controls;
|
|
using Dashboard.Drawing;
|
|
using Dashboard.Events;
|
|
using Dashboard.OpenGL;
|
|
using Dashboard.OpenTK.PAL2;
|
|
using Dashboard.Pal;
|
|
using Dashboard.StbImage;
|
|
using OpenTK.Graphics.OpenGL;
|
|
using OpenTK.Mathematics;
|
|
using OpenTK.Platform;
|
|
using TK = OpenTK.Platform.Toolkit;
|
|
|
|
TK.Init(new ToolkitOptions()
|
|
{
|
|
ApplicationName = "DashTerm",
|
|
Windows = new ToolkitOptions.WindowsOptions()
|
|
{
|
|
EnableVisualStyles = true,
|
|
IsDPIAware = true,
|
|
},
|
|
FeatureFlags = ToolkitFlags.EnableOpenGL,
|
|
});
|
|
|
|
Application app = new Pal2Application()
|
|
{
|
|
GraphicsApiHints = new OpenGLGraphicsApiHints()
|
|
{
|
|
Version = new Version(3, 2),
|
|
ForwardCompatibleFlag = true,
|
|
DebugFlag = true,
|
|
Profile = OpenGLProfile.Core,
|
|
sRGBFramebuffer = true,
|
|
|
|
SwapMethod = ContextSwapMethod.Undefined,
|
|
|
|
RedColorBits = 8,
|
|
GreenColorBits = 8,
|
|
BlueColorBits = 8,
|
|
AlphaColorBits = 8,
|
|
Multisamples = 0,
|
|
|
|
SupportTransparentFramebufferX11 = true,
|
|
}
|
|
};
|
|
|
|
CancellationTokenSource source = new CancellationTokenSource();
|
|
|
|
app.Initialize();
|
|
app.ExtensionRequire<StbImageLoader>();
|
|
app.ExtensionLoad(new BlurgTextExtension(new BlurgTextExtensionFactory()));
|
|
|
|
|
|
PhysicalWindow window = (PhysicalWindow)app.CreatePhysicalWindow();
|
|
MessageBox box = MessageBox.Create(window, "Are you sure you want to exit?", "Confirm Exit", MessageBoxIcon.Question,
|
|
MessageBoxButtons.YesNo);
|
|
|
|
// window.Title = "DashTerm";
|
|
TK.Window.SetMinClientSize(window.WindowHandle, 300, 200);
|
|
TK.Window.SetClientSize(window.WindowHandle, new Vector2i(320, 240));
|
|
TK.Window.SetBorderStyle(window.WindowHandle, WindowBorderStyle.ResizableBorder);
|
|
// TK.Window.SetTransparencyMode(wnd, WindowTransparencyMode.TransparentFramebuffer, 0.1f);
|
|
|
|
GLDeviceContext context = (GLDeviceContext)window.DeviceContext;
|
|
|
|
context.GLContext.MakeCurrent();
|
|
context.GLContext.SwapGroup.SwapInterval = 1;
|
|
|
|
GL.Disable(EnableCap.DepthTest);
|
|
GL.Enable(EnableCap.Blend);
|
|
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
|
|
GL.ColorMask(true, true, true, true);
|
|
|
|
TK.Window.SetMode(window.WindowHandle, WindowMode.Normal);
|
|
|
|
BlurgFont font = context.ExtensionRequire<BlurgDcExtension>().Blurg
|
|
.QueryFont("Rec Mono Linear", FontWeight.Regular, false) ?? throw new Exception("Font not found");
|
|
|
|
window.EventRaised += (sender, ea) => {
|
|
if (ea is not PaintEventArgs paint)
|
|
return;
|
|
|
|
paint.DeviceContext.ExtensionRequire<IDeviceContextBase>().ScaleOverride = 1.5f;
|
|
|
|
ITexture texture = MessageBox.s_questionIcon.InternTexture(context);
|
|
context.Begin();
|
|
|
|
BlurgDcExtension blurg = context.ExtensionRequire<BlurgDcExtension>();
|
|
blurg.DrawBlurgFormattedText(new BlurgFormattedText("Hello world!", font) { DefaultSize = 64f }, new System.Numerics.Vector3(24, 24, 1));
|
|
|
|
context.End();
|
|
};
|
|
|
|
app.Run(true, source.Token);
|
|
|
|
|
|
class BlurgTextExtensionFactory : IBlurgDcExtensionFactory
|
|
{
|
|
public BlurgDcExtension CreateExtension(BlurgTextExtension appExtension, DeviceContext dc)
|
|
{
|
|
return new BlurgGLExtension();
|
|
}
|
|
};
|