aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/UI/Helpers/IGlContextExtension.cs
blob: e69774c3072e62d8bc5af2666505100736257e6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Avalonia.OpenGL;
using SPB.Graphics.OpenGL;
using System;

namespace Ryujinx.Ava.UI.Helpers
{
    internal static class IGlContextExtension
    {
        public static OpenGLContextBase AsOpenGLContextBase(this IGlContext context)
        {
            var handle = (IntPtr)context.GetType().GetProperty("Handle").GetValue(context);

            if (OperatingSystem.IsWindows())
            {
                return new AvaloniaWglContext(handle);
            }
            else if (OperatingSystem.IsLinux())
            {
                return new AvaloniaGlxContext(handle);
            }

            return null;
        }
    }
}