SPBOpenGLContext.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. namespace Ryujinx.Ui
  8. {
  9. class SPBOpenGLContext : IOpenGLContext
  10. {
  11. private OpenGLContextBase _context;
  12. private NativeWindowBase _window;
  13. private SPBOpenGLContext(OpenGLContextBase context, NativeWindowBase window)
  14. {
  15. _context = context;
  16. _window = window;
  17. }
  18. public void Dispose()
  19. {
  20. _context.Dispose();
  21. _window.Dispose();
  22. }
  23. public void MakeCurrent()
  24. {
  25. _context.MakeCurrent(_window);
  26. }
  27. public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
  28. {
  29. OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);
  30. NativeWindowBase window = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100);
  31. context.Initialize(window);
  32. context.MakeCurrent(window);
  33. GL.LoadBindings(new OpenToolkitBindingsContext(context));
  34. context.MakeCurrent(null);
  35. return new SPBOpenGLContext(context, window);
  36. }
  37. }
  38. }