SILD.NET -Fenster flackern, wenn Sie Skisharp verwendenC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 SILD.NET -Fenster flackern, wenn Sie Skisharp verwenden

Post by Anonymous »

Mein Ziel ist es, Skiettharp -Leinwand im Fenster Silk.net zu erstellen. Es ist ein einfaches Programm, um die Rektionen der runden Grenzen zu ändern. Wenn ich meinen Code ausführe, flackert mein Fenster. < /P>
Mein Code: < /p>
using Silk.NET.Windowing;
using Silk.NET.OpenGL;
using SkiaSharp;

class Program
{
private static IWindow window;
private static GL gl;
private static GRGlInterface grgInterface;
private static GRContext grContext;
private static SKSurface surface;
private static SKCanvas canvas;
private static GRBackendRenderTarget renderTarget;
private static SKPaint TestBrush;

static void Main(string[] args)
{
var options = WindowOptions.Default;
options.Size = new Silk.NET.Maths.Vector2D(800, 600);
options.Title = "Silk.NET with SkiaSharp Triangle";

window = Window.Create(options);

window.Load += OnLoad;
window.Render += OnRender;

window.Run();
}

private static void OnLoad()
{
grgInterface = GRGlInterface.Create();
grContext = GRContext.CreateGl(grgInterface);
renderTarget = new GRBackendRenderTarget(window.Size.X, window.Size.Y, 0, 8, new GRGlFramebufferInfo(0, (uint)SizedInternalFormat.Rgba8));
surface = SKSurface.Create(grContext, renderTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
canvas = surface.Canvas;

TestBrush = new SKPaint
{
Color = SKColors.White,
IsAntialias = true,
Style = SKPaintStyle.Fill,
TextAlign = SKTextAlign.Center,
TextSize = 24
};
}

private static void OnRender(double delta)
{
canvas.Clear(SKColors.CornflowerBlue);

TestBrush.Color = SKColors.White;
canvas.DrawRoundRect(new SKRoundRect(new SKRect(0, 0, 256, 256), (float)Math.Max(Math.Sin(-delta) * 128.0f, 0)), TestBrush);

TestBrush.Color = SKColors.Black;
canvas.DrawText("Hello, World!", 128, 300, TestBrush);

canvas.Flush();
window.SwapBuffers();
}
}
< /code>
HINWEIS: Ich verwende letztes Silk.net 2.21 und Skisharp 2.28.8. Code für dieses Beispiel, das ich von diesem GIST genommen habe, bei dem Openentk anstelle von Silk.net verwendet wurde. Dieses Beispiel funktioniert perfekt.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post