using Microsoft.Maui.Graphics.Skia;
using SkiaSharp;
using SkiaSharp.Views.Maui;
using SkiaSharp.Views.Maui.Controls;
using System;
namespace OpenGLTest;
public partial class OGLWidget : SKGLView, ISKGLViewController
{
protected GRContext glContext;
protected SKSize canvasSize = new SKSize(640, 480);
protected SKCanvas canvas;
protected SKImageInfo info;
protected SKRect drawRect;
protected SKSurface surface;
public OGLWidget() : base()
{
}
public SKSize GetCanvasSize(GetPropertyValueEventArgs<SKSize> args)
{
return canvasSize;
}
public GRContext GetGRContext(GetPropertyValueEventArgs<GRContext> args)
{
return glContext;
}
protected override void OnPaintSurface(SKPaintGLSurfaceEventArgs args)
{
// call the base method
base.OnPaintSurface(args);
ICanvas icanvas = new SkiaCanvas() { Canvas = args.Surface.Canvas };
icanvas.EnableDefaultShadow(1.0f);
surface = args.Surface;
drawRect = new SKRect(0, 0, info.Width, info.Height);
canvas = surface.Canvas;
// draw on the canvas
canvas.Flush();
}
protected override void OnTouch(SKTouchEventArgs e)
{
base.OnTouch(e);
}
}