GraphicsManger.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using FontStashSharp;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Veldrid.Common
  8. {
  9. internal class GraphicsManger:IDisposable
  10. {
  11. private bool disposedValue;
  12. public GraphicsDevice Device { get; }
  13. public ShaderManger ShaderManger { get; }
  14. public GraphicsManger(GraphicsDevice device)
  15. {
  16. Device = device;
  17. CommandList = Device.ResourceFactory.CreateCommandList();
  18. GLSLManger.Default.Init();
  19. ShaderManger = new ShaderManger(Device);
  20. FontManger.Instance.AddFontDirectory(Environment.CurrentDirectory+"\\Fonts");
  21. }
  22. public CommandList CommandList { get; }
  23. protected virtual void Dispose(bool disposing)
  24. {
  25. if (!disposedValue)
  26. {
  27. if (disposing)
  28. {
  29. Device?.Dispose();
  30. CommandList?.Dispose();
  31. ShaderManger?.Dispose();
  32. // TODO: 释放托
  33. // 管状态(托管对象)
  34. }
  35. // TODO: 释放未托管的资源(未托管的对象)并重写终结器
  36. // TODO: 将大型字段设置为 null
  37. disposedValue = true;
  38. }
  39. }
  40. // // TODO: 仅当“Dispose(bool disposing)”拥有用于释放未托管资源的代码时才替代终结器
  41. // ~GraphicsManger()
  42. // {
  43. // // 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
  44. // Dispose(disposing: false);
  45. // }
  46. public void Dispose()
  47. {
  48. // 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
  49. Dispose(disposing: true);
  50. GC.SuppressFinalize(this);
  51. }
  52. }
  53. }