C
C#13mo ago
r2d25551

❔ How to connect events

I am trying to connect the ISKGLViewController.GetCanvasSize event (https://learn.microsoft.com/en-us/dotnet/api/skiasharp.views.maui.controls.iskglviewcontroller.getcanvassize?view=skiasharp-views-maui-2.88) to my implementation.
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);
}
}
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);
}
}
But I do not know how to do so.
ISKGLViewController.GetCanvasSize Event (SkiaSharp.Views.Maui.Contr...
Learn more about the SkiaSharp.Views.Maui.Controls.ISKGLViewController.GetCanvasSize in the SkiaSharp.Views.Maui.Controls namespace.
2 Replies
r2d25551
r2d25551OP13mo ago
Do I have this setup correctly?
Accord
Accord13mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server