SPBOpenGLContext.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using OpenTK;
  2. using OpenTK.Graphics;
  3. using OpenTK.Graphics.OpenGL;
  4. using Ryujinx.Graphics.OpenGL;
  5. using SPB.Graphics;
  6. using SPB.Graphics.OpenGL;
  7. using SPB.Platform;
  8. using SPB.Windowing;
  9. namespace Ryujinx.Ui
  10. {
  11. class SPBOpenGLContext : IOpenGLContext
  12. {
  13. private OpenGLContextBase _context;
  14. private NativeWindowBase _window;
  15. private SPBOpenGLContext(OpenGLContextBase context, NativeWindowBase window)
  16. {
  17. _context = context;
  18. _window = window;
  19. }
  20. public void Dispose()
  21. {
  22. _context.Dispose();
  23. _window.Dispose();
  24. }
  25. public void MakeCurrent()
  26. {
  27. _context.MakeCurrent(_window);
  28. }
  29. public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
  30. {
  31. OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);
  32. NativeWindowBase window = PlatformHelper.CreateOpenGLWindow(FramebufferFormat.Default, 0, 0, 100, 100);
  33. context.Initialize(window);
  34. context.MakeCurrent(window);
  35. GL.LoadBindings(new OpenToolkitBindingsContext(context));
  36. context.MakeCurrent(null);
  37. return new SPBOpenGLContext(context, window);
  38. }
  39. }
  40. }