/ src / Ryujinx / UI / Renderer / SPBOpenGLContext.cs
SPBOpenGLContext.cs
 1  using OpenTK.Graphics.OpenGL;
 2  using Ryujinx.Graphics.OpenGL;
 3  using SPB.Graphics;
 4  using SPB.Graphics.OpenGL;
 5  using SPB.Platform;
 6  using SPB.Windowing;
 7  
 8  namespace Ryujinx.Ava.UI.Renderer
 9  {
10      class SPBOpenGLContext : IOpenGLContext
11      {
12          private readonly OpenGLContextBase _context;
13          private readonly NativeWindowBase _window;
14  
15          private SPBOpenGLContext(OpenGLContextBase context, NativeWindowBase window)
16          {
17              _context = context;
18              _window = window;
19          }
20  
21          public void Dispose()
22          {
23              _context.Dispose();
24              _window.Dispose();
25          }
26  
27          public void MakeCurrent()
28          {
29              _context.MakeCurrent(_window);
30          }
31  
32          public bool HasContext() => _context.IsCurrent;
33  
34          public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
35          {
36              OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);
37              NativeWindowBase window = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100);
38  
39              context.Initialize(window);
40              context.MakeCurrent(window);
41  
42              GL.LoadBindings(new OpenTKBindingsContext(context.GetProcAddress));
43  
44              context.MakeCurrent(null);
45  
46              return new SPBOpenGLContext(context, window);
47          }
48      }
49  }