aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Controls/IGlContextExtension.cs
blob: 79d6658d65739353517483d9d96fa5972946bdf5 (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.Controls
{
    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;
        }
    }
}